Wednesday 31 October 2012

Checkbox Button For Checked Checkbox Using Javascript

Using javascript for check and uncheck all checkbox on click, There is two type button both are different like check all and uncheck all.





Please choose your sports which you likes.

Hockey
Fooball
Tennis
Cricket
Badminton
Basket Ball
Volley Ball
Long Jump
High Jump
Shotput


The javascript code is following, which do this all action. Take a look on that and remeber these thing is very easy and you will need to learn about these action



function check_all(formName){
    for (i = 0; i < formName.length; i++){
        formName[i].checked = true ;
    }
}
function uncheck_all(formName){
    for (i = 0; i < formName.length; i++){
        formName[i].checked = false ;
    }
}

Just you need to follow following things, keep it in mind when you are going to do this.

1. All checkbox need to same name.

2. Give to form name in your form tag.

These thing you need to know. Following giving working code just you need to copy and paste in our page and run.


This is javascript check and uncheck code.

No comments:

Post a Comment