drop down and hide/display issue... PLEASE HELP

Discussion in 'JavaScript' started by DrivingTraffic.com, May 19, 2009.

  1. #1
    I have two drop down menus, I only want the second one to display if "NO" is selected on the first one.

    I've been trying a few different things but my javascript really isn't very good.

    So basically IF no is selected in from first drop down, THEN display <tr>... Else don't show it. And by default it should NOT show as well.

    Any help is greatly appreciated!
     
    DrivingTraffic.com, May 19, 2009 IP
  2. JavaScriptBank.com

    JavaScriptBank.com Peon

    Messages:
    141
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    JavaScriptBank.com, May 19, 2009 IP
  3. samster7

    samster7 Banned

    Messages:
    170
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi there here is complete code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="javascript">
    function setdd2()
    {
    if(document.getElementById("dropdown1").value == "no")
    {
    document.getElementById("cntdd2").style.display = "block";
    }
    else
    {
    document.getElementById("cntdd2").style.display = "none";
    }
    }
    </script>
    </head>

    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="30"><select name="dropdown1" id="dropdown1" onchange="setdd2()">
    <option value="null">Select</option>
    <option value="yes">Yes</option>
    <option value="no">No</option>
    </select> </td>
    </tr>
    <tr>
    <td><div id="cntdd2" style="display:none"><select name="dropdown2" id="dropdown2">
    <option value="null">Select</option>
    <option value="yes">Yes</option>
    <option value="no">No</option>
    </select></div></td>
    </tr>
    </table>
    </body>
    </html>
     
    samster7, May 19, 2009 IP