A good use of the JS code snippet, to determine the check box selection, all do not select, reverse selection, a must choose
Take a note, move it.
Ideas:
Modify the selected status of the data, get all the input boxes to see if there is a selected state
check box Select all, uncheck, reverse, must select one</title> <meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/> <script language= " JavaScript ">//Form Validation functionCheck () {varids = Document.getelementsbyname ("IDs")); varFlag =false ; for(vari=0;i<ids.length;i++){ if(ids[i].checked) {flag=true ; Break ; } } if(!flag) {Alert ("Please select at least one item!" "); return false ; } } //Select All functioniselect () {//where the function number cannot be a select its JS reserved word varids = Document.getelementsbyname ("IDs")); varall = document.getElementById ("All"); for(vari=0;i<ids.length;i++) {ids[i].checked=all.checked; } } //Select All functionSelectAll () {varids = Document.getelementsbyname ("IDs")); for(vari=0;i<ids.length;i++) {ids[i].checked=true; } } //all No functionSelectnone () {varids = Document.getelementsbyname ("IDs")); for(vari=0;i<ids.length;i++) {ids[i].checked=false; } } //Inverse Selection functionSelectinvert () {varids = Document.getelementsbyname ("IDs")); for(vari=0;i<ids.length;i++){ if(ids[i].checked) ids[i].checked=false ; Elseids[i].checked=true ; } } </script> Script ">//form validation function check () {var ids = Document.getelementsbyname (" IDs "); var flag = false; for (Var i=0;i<ids. length;i++) {if (ids[i].checked) {flag = true; break;}} if (!flag) {alert ("Please select at least one item!"). "); return false; }}//Select All function iselect () {//The function number cannot be a select which is the JS reserved word var ids = document.getelementsbyname ("IDs"); var all = Document.gete Lementbyid ("All"); for (Var i=0;i<ids.length;i++) {ids[i].checked=all.checked;}} Select All function SelectAll () {var ids = Document.getelementsbyname ("IDs"); for (Var i=0;i<ids.length;i++) {Ids[i]. Checked=true; }}//All function Selectnone () {var ids = Document.getelementsbyname ("IDs"); for (Var i=0;i<ids.length;i++) {Ids[i].che Cked=false; }}//Counter-select function Selectinvert () {var ids = Document.getelementsbyname ("IDs"); for (Var i=0;i<ids.length;i++) {if (ids[i ].checked) Ids[i].checked=false; else ids[i].checked=true; }} </script>
JS judgment check box Select all, uncheck, reverse, a must select one