change textbox on change of dropdown

Discussion in 'JavaScript' started by mmelen, Jul 2, 2008.

  1. #1
    I want there to be 2 choices of dropdown.
    For example sake, "YES" and "NO".
    When "YES" is chosen, I want the initial value of the textbox to be "YEA!" and if "NO" is chosen, then the value of the textbox is "OH NO!"

    How do I do that?

    thanks in advance!
     
    mmelen, Jul 2, 2008 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Pretty simple.


    <select onChange="javascript:document.getElementById('msg').value=this.value">
      <option value="Select one option">Select</option>
      <option value="OH YEA">YES</option>
      <option value="OH NO">NO</option>
    </select>
    
    <input id="msg" name="msg" type=text size=20>
    HTML:
    I hope it helps.

    regards
     
    Vooler, Jul 3, 2008 IP