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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

disabling a text box based on a menu choice..

Status
Not open for further replies.

fgeorge

Programmer
Jun 28, 2002
76
NG
i have a menu and a text box on the same page, in the same form, the menu before the text box..

i want to create a situation whereby, when i choose a certain option in the menu, the text box is disabled and cannot receive focus..

the text box will only be enabled when i select the other options..
thanks
 
In the select tag, add:

Code:
onChange=disableText(this.options[this.selectedIndex].value);

In your script section, add:

Code:
function disableText(val)
{
 var valOfInterest = "HMO"; //for example
 if(val == valOfInterest)
  textBox.disabled = true;
 else
  textBox.disabled = false;
}

Is that what you're after?

--Dave
 
Hi,

Dont know whether this would be any help but I asked the opposite of your question. I wanted a combo box to appear only if the user selected a particular option.

thread216-617017 I would let you know to see if the code would help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top