[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

Javascript onChange Script To Make Form Area Appear or Disappear

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.
0
gianchi66
Asked:
gianchi66
  • 3
1 Solution
 
Michel PlungjanIT ExpertCommented:
<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>
0
 
Michel PlungjanIT ExpertCommented:
0
 
gianchi66Author 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.
0
 
Michel PlungjanIT ExpertCommented:
Ohhh, I thought it was the pints...
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now