1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

form HELP - dependent 2 dropdown select

Discussion in 'JavaScript' started by KingCobra, Oct 26, 2010.

  1. #1
    I have form and two dropdown select list.
    I want make them dependent each other. That means if a option selected from one select list then other dropdown select list will be blank.

    I think its simple in JavaScript but I can't make it.

    PLEASE HELP ME.
    Thanks
     
    KingCobra, Oct 26, 2010 IP
  2. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Ok, you can do like this:
    <html> 
    <head> 
     <script type="text/javascript"> 
     function someFunction(p_sDomId) {
     	document.getElementById(p_sDomId).selectedIndex = 0;
     };
    </script> 
    </head> 
    <body> 
    <form method="post">
    
    <select id="boxA" onchange="someFunction('boxB')">
    <option>-</option>
    <option value="A1">A</option>
    <option value="A2">B</option>
    <option value="A3">C</option>
    <option value="A4">D</option>
    </select>
    
    <select id="boxB" onchange="someFunction('boxA')">
    <option>-</option>
    <option value="B1">A</option>
    <option value="B2">B</option>
    <option value="B3">C</option>
    <option value="B4">D</option>
    </select>
    
    </form>
    
    </body> 
    Code (markup):
    :)
     
    wing, Oct 26, 2010 IP