The example of this article describes the implementation of JS full selection and determine whether there is a check box selection method. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
function ActionEvent (methodname) {
var form = document.forms[0];
if (Validateisselect (Form.all, form.productids)) {
form.action= ' Form.submit ();
}else{
Alert ("Please select the record to be manipulated");
}
}
function Allselect (allobj,items) {
var state = allobj.checked;
if (items.length) {
for (Var i=0;i<items.length;i++) {
if (!items[i].disabled) items[i].checked=state;
}
}else{
if (!items[i].disabled) items.checked=state;
}
}
/*
* Determine if the record is selected
*/
function Validateisselect (allobj,items) {
var state = allobj.checked;
if (items.length) {
for (Var i=0;i<items.length;i++) {
if (items[i].checked) return true;
}
}else{
if (items.checked) return true;
}
return false;
}
Copy Code code as follows:
<input type= "checkbox" Name= "All" onclick= "Javascript:allselect (This, this.form.productids)" > select all </td>
Copy Code code as follows:
<input name= "Visible" type= "button" class= "frm_btn" onclick= "javascript:actionevent (' Visible ')" value= "Operations" >
I hope this article will help you with your JavaScript programming.