SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Show/Hide Div based on Select Box Choice

    Ok so I have a select box where the value must be passed via the form. If the users selects choice B or Choice C then I want a specific div to show. If they choose choice A then I want the div to hide or remain hidden. It should be hidden on page load.
    Code:

    Code:
    <select name="Event_Type_ID">
        <option value="1">Choice A</option>
        <option value="2">Choice B</option>
        <option value="3">Choice C</option>
    </select>
    
    <div id="showme">
     Content to show if EITHER Choice B or C is chosen. Otherwise this div  should be hidden.
    </div>
    Can anyone lead me in the right direction?
    Thanks!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by webdiva1969 View Post
    Can anyone lead me in the right direction?
    Thanks!
    Set up an onchange event for the select box.

    In the function find out which option is currently selected.
    If it's the first one, hide the div, otherwise show it.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •