This article mainly introduces how to implement and determine whether a check box is selected for javascript. It involves the javascript operation checkbox technique and is of great practical value, you can refer to the examples in this article to describe how to select all js programs and determine whether there is a check box. Share it with you for your reference. The specific implementation method is as follows:
The Code is as follows:
Function actionEvent (methodname ){
Var form = document. forms [0];
If (validateIsSelect (form. all, form. productids )){
Form. action =' ';
Form. submit ();
} Else {
Alert ("select the record to be operated ");
}
}
Function allselect (allobj, items ){
Var state = allobj. checked;
If (items. length ){
For (var I = 0; I If (! Items [I]. disabled) items [I]. checked = state;
}
} Else {
If (! Items [I]. disabled) items. checked = state;
}
}
/*
* Determine whether a record is selected
*/
Function validateIsSelect (allobj, items ){
Var state = allobj. checked;
If (items. length ){
For (var I = 0; I If (items [I]. checked) return true;
}
} Else {
If (items. checked) return true;
}
Return false;
}
The Code is as follows:
Select All
The Code is as follows:
I hope this article will help you design javascript programs.