View Single Post
  #2 (permalink)  
Old 10-13-03, 08:46 AM
jewellgr jewellgr is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Michigan USA
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Han84
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()">&nbsp;&nbsp;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.
__________________
ArecaWeb Team
Gregg Kenneth Jewell
Reply With Quote