javascript for dependent dropdowns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sailajapotha
    New Member
    • Jun 2007
    • 1

    javascript for dependent dropdowns

    I have one javascript code with me,to show parent dropdown as well as child dropdown.

    <html>
    <head>
    <script type="text/javascript" language="javas cript">
    function setOptions(chos en) {
    var selbox = document.kickof f.regionId;
    selbox.options. length = 0;
    if (chosen == "SOD") {
    selbox.options[selbox.options. length] = new Option('EMEA');
    selbox.options[selbox.options. length] = new Option('NA');
    }
    if (chosen == "AQ") {
    selbox.options[selbox.options. length] = new Option('US');
    selbox.options[selbox.options. length] = new Option('AU');
    }
    }
    </script>
    </head>

    <body>
    <form action="/.drop" name="kickoff" method="post">
    <table border="0" cellpadding="1" cellspacing="3" >
    <tr>
    <td>
    <select name="system" onchange="setOp tions(document. kickoff.system. options[document.kickof f.system.select edIndex].value);">
    <option value="SOD">SOD </option>
    <option value="AQ">Auto Quote</option>
    </select>

    </td>
    </tr>
    <tr>

    <th>
    Region Code
    </th>
    <td>
    <select name="regionId" >
    <option value="EMEA" >Emiratres</option>
    <option value="NA" >NorthAmerica </option>
    </select>
    </td>

    </tr>
    <span class="button-blue">
    <input type="submit" >
    </span>
    </form>
    </body>
    </html>
    ---------------------------------------*************** ******---------------------------------------------------My question is: how to get texts in dropdown list just by passing only value of the options....I mean,per suppose,NA means NorthAmerica..
    Value=NA
    text=NothAmeric a.
    Similarly,
    Value=US
    text=UnitedStat es
    Value=AU
    text=Australia.
    If parent drop down value=SOD and text =SOD then
    child dropdown should have Emiratres ,NorthAmerica as contents in dropdown list;
    If parent drop down value=AQ and text =AutoQuote then
    child dropdown should have UnitedStates ,Australia as contents in dropdown list
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by sailajapotha
    I have one javascript code with me,to show parent dropdown as well as child dropdown.

    <html>
    <head>
    <script type="text/javascript" language="javas cript">
    function setOptions(chos en) {
    var selbox = document.kickof f.regionId;
    selbox.options. length = 0;
    if (chosen == "SOD") {
    selbox.options[selbox.options. length] = new Option('EMEA');
    selbox.options[selbox.options. length] = new Option('NA');
    }
    if (chosen == "AQ") {
    selbox.options[selbox.options. length] = new Option('US');
    selbox.options[selbox.options. length] = new Option('AU');
    }
    }
    </script>
    </head>

    <body>
    <form action="/.drop" name="kickoff" method="post">
    <table border="0" cellpadding="1" cellspacing="3" >
    <tr>
    <td>
    <select name="system" onchange="setOp tions(document. kickoff.system. options[document.kickof f.system.select edIndex].value);">
    <option value="SOD">SOD </option>
    <option value="AQ">Auto Quote</option>
    </select>

    </td>
    </tr>
    <tr>

    <th>
    Region Code
    </th>
    <td>
    <select name="regionId" >
    <option value="EMEA" >Emiratres</option>
    <option value="NA" >NorthAmerica </option>
    </select>
    </td>

    </tr>
    <span class="button-blue">
    <input type="submit" >
    </span>
    </form>
    </body>
    </html>
    ---------------------------------------*************** ******---------------------------------------------------My question is: how to get texts in dropdown list just by passing only value of the options....I mean,per suppose,NA means NorthAmerica..
    Value=NA
    text=NothAmeric a.
    Similarly,
    Value=US
    text=UnitedStat es
    Value=AU
    text=Australia.
    If parent drop down value=SOD and text =SOD then
    child dropdown should have Emiratres ,NorthAmerica as contents in dropdown list;
    If parent drop down value=AQ and text =AutoQuote then
    child dropdown should have UnitedStates ,Australia as contents in dropdown list
    Moved to Java forum.

    Comment

    • Logician
      New Member
      • Feb 2007
      • 210

      #3
      Originally posted by sailajapotha
      I have one javascript code with me,to show parent dropdown as well as child dropdown.
      Sounds like a job for SelectCascade.

      Comment

      Working...