Home > Web Front-end > JS Tutorial > body text

用Javscript实现表单复选框的全选功能_表单特效

WBOY
Release: 2016-05-16 19:13:07
Original
1150 people have browsed it

一个比较常见的全选功能,前天在弄后台的时候有看到,整理了一下。具体:
//说明:form1为表单名,mId为复选框,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> 

复选框:
说明:注意复选框的name应该与上面脚本中的document.form1.mId对应

全选按钮:
  
同样注意name=selectButton 

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!