2. "JavaScript::Squish - Reduce/Compact JavaScript code to as fe..." | +/– |
Сообщение от mehman (??) on 13-Ноя-09, 22:17 |
function checkAllFields(ref) { var chkAll = document.getElementById('checkAll'); var checks = document.getElementsByName('reset[]'); var removeButton = document.getElementById('removeChecked'); var boxLength = checks.length; var allChecked = false; var totalChecked = 0; if ( ref == 1 ) { if ( chkAll.checked == true ) { for ( i=0; i < boxLength; i++ ) { checks[i].checked = true; } } else { for ( i=0; i < boxLength; i++ ) { checks[i].checked = false; } } } else { for ( i=0; i < boxLength; i++ ) { if ( checks[i].checked == true ) { allChecked = true; continue; } else { allChecked = false; break; } } if ( allChecked == true ) { chkAll.checked = true; } else { chkAll.checked = false; } } for ( j=0; j < boxLength; j++ ) { if ( checks[j].checked == true ) { totalChecked++; } } removeButton.value = "Nulstil ["+totalChecked+"] markeret"; }
|
Высказать мнение | Ответить | Правка | Наверх | Cообщить модератору |