Tuesday, June 16, 2009

Check and Uncheck checkboxes using javascript

inside script tag

//this will mark all the checkboxes inside a form are checked.

//form1 is the form name
function checkAll() {

for(var i=0;i

if(document.forms['form1'].elements[i].type=='checkbox') {

document.forms['form1'].elements[i].checked=true; } } }
//this will mark all the checkboxes inside a form are unchecked.

//form1 is the form name

function uncheckAll() {

for(var i=0;i

if(document.forms['form1'].elements[i].type=='checkbox') {

document.forms['form1'].elements[i].checked=false; } } }
//form1 is the form name

----------------------------------------------------------------------
//this will mark the specified checkboxes inside a form are checked

//form1 -- formname

//checkboxname-- checkbox name

function selectAllFields()

{

var chk = document.form1.checkboxname;

for (i = 0; i < checked =" true">

var chk = document.form1.checkboxname;

for (i = 0; i

}

No comments: