Forum Moderators: open
The information on the screen I'm referring to comes from a database, and the checkbox name is the record ID in the DB so I have no way of building a static script that can check/uncheck these boxes since I won't know what the name is going to be.
Thanks for the script but I'm having a bit of a problem with it. Actually the script you gave me works fine. I also made a second function to UNcheck the boxes, the only difference being the function name and the value to "false". Both of these work fine when I run them as is.
The problem is that I'm trying to make a "master" checkbox where I can check/uncheck them all by checking/unchecking one box. I accomplished this with this function:
function DoTheCheck() {
if(document.form1.checkuncheckall.checked == true)
checkAllBoxes(form1)
else
uncheckAllBoxes(form1)
}
And I call it like this:
<input type="checkbox" name="checkuncheckall" value="1" onClick="Javascript:DoTheCheck()">
The form name is "form1" as you probably guessed. This script works fine in Internet Explorer, but doesn't do anything at all in Firefox. Both the function you gave me and the version of it I made to uncheck work fine when called alone in both browsers, but I'm not sure why the DoTheCheck only seems to work in internet explorer. Any ideas?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function boxCheck(frm,stat){
var frm_el=frm.elements;
var frm_ln=frm_el.length;
for(var i=0;i<frm_ln;i++){
if(frm_el[i].type=="checkbox")frm_el[i].checked=stat;
}
}
</script>
</head>
<body>
<form action="">
<input type="checkbox" />Box 1<br />
<input type="checkbox" />Box 2<br />
<input type="checkbox" />Box 3<br />
<input type="checkbox" />Box 4<br />
<input type="checkbox" />Box 5<br /><br />
<input type="checkbox"
onclick="var x=false;if(this.checked==true)x=true;boxCheck(this.form,x);" />Master Control
</form>
</body>
</html>