Javascript - Simple form script to hide/show fields

Posted by danit on Stack Overflow See other posts from Stack Overflow or by danit
Published on 2010-05-12T13:40:07Z Indexed on 2010/05/12 13:44 UTC
Read the original article Hit count: 177

Filed under:

Im looking for a simple script in javascript that i can extend, at a basic level Im looking to show 1 field based on which option from a <select> the user chooses.

<select id="options">
  <option value="spoon">Spoon</option>
  <option value="form">Fork</option>
</select>

if select=spoon {
  <input>enter your favorite soup</input>
} else {
  <input>Your gonna need a knife</input>
}

Simple JS is the key!

© Stack Overflow or respective owner

Related posts about JavaScript