Check Uncheck all the checkboxes through Javascript

18Mar09

This is the javascript code that will help you if you want to check or uncheck all the checkbox elements in your form.

function checkall(){
for(i=0; i<document.FormName.elements.length; i++){
if(document.FormName.elements[i].type==”checkbox”){
document.FormName.elements[i].checked=true;
}
}
}

function uncheckall(){
for(i=0; i<document.FormName.elements.length; i++){
if(document.FormName.elements[i].type==”checkbox”){
document.FormName.elements[i].checked=false;
}
}
}

Advertisements


No Responses Yet to “Check Uncheck all the checkboxes through Javascript”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: