Hi, I'm trying to achieve something wihich I thought would be relatively simple: When a check box is ticked a textfield1 is disabled and textfield2 is enabled (and vice versa when check box is not ticked). The code I've got so far is:
The problem I'm getting is that when clicking the checkbox the relevant fields are disabled as expected, but if you try to uncheck the checkbox after it has been previously clicked it won't uncheck the box or disable/enable the textfields.
I've tried using onmouseout, onblur, etc. rather than onclick to start the javascript function but to no avail.
I would be very grateful if someone could point out my (hopefully obvious) coding errors or offer any thoughts. Many thanks in advance!
Code:
...
<script language=javascript>
function testbox()
{
if (document.form.check1.checked = true )
{document.form.textfield1.disabled = true
document.form.textfield2.disabled = false
}
else
{document.form.textfield1.disabled = false
document.form.textfield2.disabled = true
}
}
</script>
...
<form>
<input type="checkbox" name="check1" onclick="javascript:testbox()">
<input type="text" name="textfield1">
<input type="text" name="textfield2">
</form>
...
I've tried using onmouseout, onblur, etc. rather than onclick to start the javascript function but to no avail.
I would be very grateful if someone could point out my (hopefully obvious) coding errors or offer any thoughts. Many thanks in advance!