SoFunction
Updated on 2025-02-28

Use Javascript to implement the selection of all forms check boxes

A more common selection function. I saw it when I was working on the backstage the day before yesterday and sorted it out. specific:
//Note: form1 is the form name, mId is the check box, and selectbutton is the select all button.
<script language="javascript"> 
   function selectAll()  
   { 
for (var i=0;i<document.;i++) { 
var temp=document.[i]; 
=!; 

if (document.=="Select All")
   { 
document.="Cancel all";
   } 
   else 
   { 
document.="Select All";
   } 

</script> 

Checkbox: <input name="mId" type="checkbox" value="Value of checkbox">
Note: Note that the name of the check box should correspond to the document in the above script.

Select all buttons:
<input type="button" name=selectButton value="select all" onClick="selectAll()">
Also pay attention to name=selectButton