js+jsp CheckBox full selection of specific implementation _javascript skills

Source: Internet
Author: User
Copy Code code as follows:

<script>
function func () {
var options=document.getelementsbyname ("Chkbox");
for (Var i=0;i<options.length;i++) {
if (!options[i].disabled) {
Options[i].checked=true;
}
}
}
</script>
<input Type=checkbox Name=chkbox value=1 disabled>
<input Type=checkbox Name=chkbox value=1>
<input Type=checkbox Name=chkbox value=1>
<input Type=checkbox Name=chkbox value=1>
<input Type=button value= "test" onclick= "func ()" >

Use JavaScript.
Copy Code code as follows:

<body>
<script>
function kk () {
var handleel = document.getElementById ("Kkhandler");
var els = document.getelementsbyname ("KK");
for (i=0;i<els.length;i++) {
els[i].checked = handleel.checked;
}

}
</script>
<input type=checkbox onclick= "KK ()" Name= "Kkhandler" > Full selection <br>
<input type=checkbox name= "KK" >
<input type=checkbox name= "KK" >
</body>

2:
Copy Code code as follows:

<form name= "form" id= "Form1" >
<input type= "checkbox" Name= "id" value= "id=" Checkbox1 ">1"
<input type= "checkbox" Name= "id" value= "id=" Checkbox2 ">2"
<input type= "checkbox" Name= "chose" value= "" onclick= "SelectAll ()" id= "Checkbox5" >allselect
</form>
<script>
function SelectAll ()
{
if (!document.form.id.length) {
if (document.form.chose.checked) {
Document.form.id.checked=true;
}
else{
Document.form.id.checked=false;
}
}
else{
for (Var i=0;i<document.form.id.length;i++) {
if (document.form.chose.checked) {
Document.form.id[i].checked=true;
}
else{
Document.form.id[i].checked=false;
}
}
}
}
</script>

3:
Copy Code code as follows:

<input type= ' checkbox ' name= ' info ' value= ' a ' >
<input type= ' CheckBox ' name= ' info ' value= ' B ' >
<input type= ' checkbox ' name= ' info ' value= ' C ' >
<input type= ' checkb Ox ' name= ' info ' value= ' d ' >
<input type= ' checkbox ' name= ' info ' value= ' e ' ><br>
<input ' bu Tton ' value = ' All selected ' onclick= ' Check_all (); ' >
<script>
Function Check_all () {
arr = document.getelementsbyname (' info ');
for (i=0;i<arr.length;i++) {
arr[i].checked = true;
}
}
</script>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.