Home >Web Front-end >JS Tutorial >Use Javscript to implement the all-select function of form check boxes_Form special effects

Use Javscript to implement the all-select function of form check boxes_Form special effects

WBOY
WBOYOriginal
2016-05-16 19:13:071219browse

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>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn