Link to home
Start Free TrialLog in
Avatar of g118481
g118481

asked on

How to disable a form field?

I need to disable a form field when "EV" is selected from a drop-down list.
The drop-down field already has an "onClick" event assigned to it.

Any ideas how to do this?
Avatar of mrichmon
mrichmon

You can assign multiple events to the onClick or onCHange (which is usually better for a drop-down).

Basically you just use javascript to change the status to disabled.

http://www.quirksmode.org/js/disabled.html
Avatar of g118481

ASKER

This is only part of what I need.

If "EV" from the drop down list is selected in the form, then the other drop down list "reasonout" needs to be disabled.
How can I do that?

Increasing points.
if(document.formname.dropdownname.options[document.formname.dropdownname.selectedIndex].value == "EV")
{   code to disable goes here   }
Avatar of g118481

ASKER

Mitch,

Could you be more specific of how to setup the code, where in relation to the form it goes, and how it works?
So, if this were my form where would I insert the code?

<form>
<select name=event>
<option value=EV>EV</option>
<option value=AT>AT</option>
</select>

<select name=reasonout>
<option value=EV>EV</option>
<option value=AT>AT</option>
</select>

Just trying to ask the correct question in order to understand your suggestion more fully.
Thanks
Who is mitch?  Do you have this question posted somwhere else as well?
Avatar of g118481

ASKER

sorry, i thought m stood for Mitch.
Avatar of g118481

ASKER

MRICHMON,

Sorry for calling you Mitch, it was an honest mistake.  

Could you be more specific of how to setup the code, where in relation to the form it goes, and how it works?
So, if this were my form where would I insert the code?

<form>
<select name=event>
<option value=EV>EV</option>
<option value=AT>AT</option>
</select>

<select name=reasonout>
<option value=EV>EV</option>
<option value=AT>AT</option>
</select>

Just trying to ask the correct question in order to understand your suggestion more fully.
Thanks
SOLUTION
Avatar of dgrafx
dgrafx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of g118481

ASKER

Is there a way to have two "onchange" events for the "event" drop-down select?

As I mentioned in my initial posting, this event drop-down already has an onchange event that populates a third drop-down list.

Any suggestions?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of g118481

ASKER

This works perfect.
Thanks.