We help IT Professionals succeed at work.

Javascript onChange Script To Make Form Area Appear or Disappear

417 Views
Last Modified: 2012-05-05
In a website I am working on, I want to display/hide an area of a form according to the value selected from a scroll-down by the user.
Comment
Watch Question

Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
<select onChange="var val=this.options[this.selectedIndex].value;
document.getElementById('otherDiv').style.display=(val=='other')?'':'none'">
<option value="">Please select</option>
<option value="A">A</option>
<option value="other">Other</option>
</select>
<div id="other" style="display:none"><input type="text" name="otherValue" value=""></div>
IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I cracked up.

Isn't that beautiful? I even forgot I had asked that question already...

Do you have kids? That's how you loose your memory.
Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
Ohhh, I thought it was the pints...
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.