I have a web page with a checkbox and a textbox. When I check/uncheck the checkbox, I want to disable/enable the textbox and change the textbox background color.
I am using the code below. It works except the color change is not apparent until I physically click on the textbox. Can I make the color change happen immediatly when I change the checkbox?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<SCRIPT LANGUAGE = "JAVASCRIPT">
<!--
function ChkCb() {
if( MyForm.IDcb.checked ) {
MyForm.IDtx.style.backgroundColor = "#D4D2D2";
MyForm.IDtx.style.color="#D4D2D2"
MyForm.IDtx.disabled = true;
} else {
MyForm.IDtx.style.backgroundColor = "#FBFBFB";
MyForm.IDtx.style.color="#000000"
MyForm.IDtx.disabled = false;
}
}
//-->
</script>
</head>
<body>
<form method="POST" name="MyForm" action="myscript.cgi">
Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p><input type="checkbox" name="cb" id="IDcb" value="ON" onchange=ChkCb() ></p>
<p><input type="text" name="tx" size="20" id="IDtx"></p>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>