Set text based on Form <select> value

Posted by danit on Stack Overflow See other posts from Stack Overflow or by danit
Published on 2010-05-12T12:24:19Z Indexed on 2010/05/12 12:44 UTC
Read the original article Hit count: 323

Filed under:

I have the following <select> in a form:

<select style="width: 100px; text-align: center;">
  <option value="email">Email</option>
  <option value="telephone">Phone</option>
</select>

The default option is Email so the following <input> is show:

<p class="email_form">Please supply your Email Address</p>
<input onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;" style="width: 270px" type="email" name="email" id="email" value="[email protected]">

However if they choose telephone I want to change the above to ask for a telephone number?

© Stack Overflow or respective owner

Related posts about JavaScript