This article describes the method of selecting all js and determining whether there is a check box selected. Share it for your reference. The specific implementation method is as follows:
The code copy is as follows: function actionEvent(methodname){
var form = document.forms[0];
if(validateIsSelect(form.all, form.productids)){
form.action='<html:rewrite action="/control/product/manage"/>';
form.submit();
}else{
alert("Please select the record to operate");
}
}
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 whether the record has been 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 the code as follows: <INPUT TYPE="checkbox" NAME="all" onclick="javascript:allselect(this, this.form.productids)">Select all</td>
Copy the code as follows: <input name="visible" type="button" onClick="javascript:actionEvent('visible')" value="action">
I hope this article will be helpful to everyone's JavaScript programming.