Sunday, July 19, 2009

how can select multiple check box using javascriipt

<script type="text/javascript">

//Nanhe Kumar

var checkflag = "false";

function SelectAll(field) {



if (checkflag == "false") {



document.getElementById("selectall").value= 'Unchek All';

for (i = 0; i < field.length; i++) {

field[i].checked = true;

}

checkflag = "true";

return "Uncheck All";

} else {

document.getElementById("selectall").value= 'Sellect All';

for (i = 0; i < field.length; i++) {

field[i].checked = false;

}

checkflag = "false";

return "Select All";

}

}



</script>

<form method="post" action="" name="formuser" id="formuser" >



<input id="selectall" name="selectall" value="Select All" onclick="SelectAll(document.formuser['uid[]']);" type="checkbox"> Sellect All <br>

<input name="uid[]" value="1" type="checkbox"> One<br>

<input name="uid[]" value="2" type="checkbox"> two<br />

<input name="uid[]" value="3" type="checkbox"> three<br />

<input name="uid[]" value="4" type="checkbox"> four<br />

<input name="uid[]" value="5" type="checkbox"> five<br />

<input name="uid[]" value="6" type="checkbox"> six<br />

<input name="uid[]" value="7" type="checkbox"> seven



</form>

No comments:

Post a Comment