Drop Down menu select, then textbox apears.

Discussion in 'JavaScript' started by Jake-Johnson, Jun 10, 2009.

  1. #1
    I'm pretty sure this would have some Javascript in it.. How would I do this...

    Here is my form:

    
        <select class='input'>
         <option name='digitalpoint'>Digital Point</option>
         <option name='sitepoint'>Site Point</option>
         <option name='ebay'>E-Bay</option>
         <option name='other'>Other..</option>
        </select>
    
    PHP:
    I'd like it so when you select "Option", a new text box appears below the dropdown where you can insert the "Other" option.
     
    Jake-Johnson, Jun 10, 2009 IP
  2. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #2
    How's this?

    <html>
    <head>
    <script type="text/javascript">
    function showOther(sValue)
    {
        var sDisplay = 'none';
        if ( sValue == 'other' )
        {
            sDisplay = 'block';     
        }
    
        document.getElementById('other').style.display = sDisplay;
    }
    </script>
    </head>
    
    <body>
      <form>
        <select class="input" onchange="showOther(this.value);">
          <option value="digitalpoint">Digital Point</option>
          <option value="sitepoint">Site Point</option>
          <option value="ebay">E-Bay</option>
          <option value="other">Other..</option>
        </select>
    
        <input type="textbox" name="other" id="other" style="display: none;" />
      </form>
    </body>
    </html>
    HTML:
     
    clarky_y2k3, Jun 10, 2009 IP
  3. Jake-Johnson

    Jake-Johnson Peon

    Messages:
    839
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Exactly what I needed. Thank-you very much, clarky_y2k3.
     
    Jake-Johnson, Jun 10, 2009 IP