[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
How_To_Javascript_Disable_Enable_Form_Elements
The function checks if the checkbox control is checked or not. If it is, the textbox control will be disabled.
Related threads:
disabling form elements
JavaScript FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
How_To_Javascript_Disable_Enable_Form_Elements
How to disable or enable form elements?
The example shows how to change the status of a form element from another form element.<html>
<head>
<script language="javascript">
function Change()
{
if (document.form1.check1.checked == true)
{ document.form1.text1.disabled = true; }
else
{ document.form1.text1.disabled = false; }
}
</script>
</head>
<body>
<form name="form1">
<input type="checkbox" name="check1" onClick="Change()"/>
<input type="text" name="text1" id="text1" value="Type some text">
</form>
</body>
</html>The function checks if the checkbox control is checked or not. If it is, the textbox control will be disabled.
Related threads:
disabling form elements
JavaScript FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
