I am currently working on an ASP page where I create a lot of
different check boxes. I have some checkboxes that are Windows
platforms and some that are solaris platforms. I want a control
checkbox over the Windows ones to turn them all on or all off, and the
same with the solaris.
One of the control check boxes looks something like this:
<input type="checkbox" name="objRS("ProductId") & "_solaris"
value=""0"" onClick=""checkAll(this.form,name);"">
This gives me a check box with a name that looks like:
194_solaris
194 is the productID for a product at my company, and solaris is just
to tell if its windows or solaris. Now I know this is the name of
that checkbox this is NOT my problem.
Now when I pass the onClick=""checkAll(this.form,name) part I go to:
<SCRIPT LANGUAGE="JavaScript">
function checkAll(form, CheckBoxName)
var myVar = CheckBoxName
if (form.CheckBoxName.checked == true){ <-------- Problem Line
for (i=0; i<form.elements.length; i++)
{
if (form.elements[i].id == myVar)
form.elements[i].checked = true;
}
}else {
for (i=0; i<form.elements.length; i++)
{
if (form.elements[i].id == myVar)
form.elements[i].checked = false;
}
</script>
Now when I call this I get an error thats says:
"CheckBoxName.checked is null or not declared"
Well I know good and well CheckBoxName.checked is not declared, but
the VALUE of CheckBoxName is a valid name. I want the content of the
variable named CheckBoxName not the name. How can I do this?