Home > Article > Web Front-end > Use Javscript to implement the all-select function of form check boxes_Form special effects
A relatively common select all function, I saw it when I was working on the backend the day before yesterday, and I sorted it out. Specific:
// Description: form1 is the form name, mId is the check box, selectbutton is the select all button
Check box:
Note: Note The name of the check box should correspond to the document.form1.mId in the above script
Select all button:
Also note the name=selectButton <script> <BR> function selectAll() <BR> { <BR>for (var i=0;i<document.form1.mId.length;i++) { <BR>var temp=document.form1.mId[i]; <BR>temp.checked=!temp.checked; <BR>} <BR> if (document.form1.selectButton.value=="全部选择") <BR> { <BR> document.form1.selectButton.value="取消全选"; <BR> } <BR> else <BR> { <BR> document.form1.selectButton.value="全部选择"; <BR> } <BR>} <BR></script>