View Full Version : How to enabled or disabled input text using a checkbox
Hi everyone,
I will like to know what the code for enable or disable a input text using a checkbox? For example, if i click on this check box,the input text will be enabled.
Thx alot
jewellgr
10-13-03, 09:46 AM
Hi everyone,
I will like to know what the code for enable or disable a input text using a checkbox? For example, if i click on this check box,the input text will be enabled.
Thx alot
Here is some sample code that will enable the textbox when you click the checkbox.
<html>
<head>
<title>Untitled</title>
<script>
function enable()
{
document.myForm.textbox.disabled = false;
}
</script>
</head>
<body>
<form name="myForm">
<input type="checkbox" onclick="enable()"> Enable<br><br>
<input type="text" name="textbox" value="Hello World" disabled>
</form>
</body>
</html>
-----------------------------------
To disable the text box again you can make a new function and just have disabled = true;
Hope this helps.
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.