Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable/disable text field upon change of combo box

Status
Not open for further replies.

paulobrads

Programmer
Jul 13, 2006
28
GB
Hi,

This isn't that tricky but I've scoured the web and can't find anything.

I'm looking for code that will only enable a disabled text field if a certain value is selected within a combo box. Obviously it will need to be disabled again if the combo box option changes again.

Cheers in advance,
Paul.
 
Here's an example:
Code:
<script type="text/javascript">

function disableField(obj) {
   var textField = document.getElementById("blah");
   if (obj.value == "enable") {
      textField.disabled = false;
   }
   else {
      textField.disabled = true;
   }
}

</script>
<body>
<input type="text" id="blah">
<select onchange="disableField(this)">
   <option value="enable" selected="selected">enable</option>
   <option value="disable">disable</option>
</select>
</body>

-kaht

Looking for a puppy?

[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top