[nycphp-talk] Javascript "select all" feature?
jon baer
jonbaer at jonbaer.net
Wed Apr 14 10:22:20 EDT 2004
try this snippet ...
<html><body>
<script language="Javascript">
function checkAll(theForm, cName) {
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].className.indexOf(cName) !=-1)
if (theForm.elements[i].checked == true) {
theForm.elements[i].checked = false;
} else {
theForm.elements[i].checked = true;
}
}
</script>
<form id="myform">
<input type="checkbox" class="movecheck" name="move[]"><br>
<input type="checkbox" class="movecheck" name="move[]"><br>
<input type="checkbox" class="movecheck" name="move[]"><br>
<input type="checkbox" class="movecheck" name="move[]"><br><br>
<input type="checkbox"
onclick="checkAll(document.getElementById('myform'),
'movecheck');"><strong>Select All/None</strong>
</form>
</body></html>
More information about the talk
mailing list