Hi again,
I enhanced the code a bit. Now it loops through the form and disables all elements that are textboxes (type == 'text')
It's more elegant and saves typing.
I used some standard notation this time (check1, text1 etc)
<html>
<head>
<script language="javascript">
function checkBox(cbox)
{
box = eval(cbox);
box.checked = !box.checked;
changeBox();
}
function changeBox()
{
var max = document.forms[0].elements.length; //count all the elements in the form
for (i=0; i<max; i++)
{
element = document.forms[0].elements[i];
if (document.form1.check1.checked == true)
{
if (element.type == "text")
{
element.disabled=true;
}
}
else
{
element.disabled=false;
} //end if
} // end for
} // end function
</script>
</head>
<body>
<form name="form1">
<input type="checkbox" name="check1">
<a class="chekbox" href="#" onClick="checkBox('document.form1.check1');return false">Check it!</a><br>
<input type="text" name="text1" id="text1" value="Type some text">
<input type="text" name="text2" id="text2" value="Type some text">
<input type="text" name="text3" id="text3" value="Type some text">
</form>
</body>
</html>
Lillu
The Purple Couch
http://www.geocities.com/lillamarta