All pastes #802883 Raw Edit

Unnamed

public text v1 · immutable
#802883 ·published 2007-11-30 18:41 UTC
rendered paste body
<script>
               products = {
                    Aramis : [
                    {build:17, version:'v0.0.0'},
                    {build:18, version:'v0.0.1'}
                    ],

                    Sofia : [
                    {build:17, version:'v0.0.0'},
                    ]
               }


               function showVersions()
               {
                    software = "Aramis";
                    selectBox = document.test.buildSelect;
                    document.write("<p>Select is " + selectBox + "</p>");
                    document.write("<p>Software is " + software + "</p>");

                    clearList(selectBox);
                    document.write("<p>Length is " + selectBox.length+"</p>");
                    for(appName in products)
                    {
                         document.write("<p>App name is " + appName);
                         if(appName == software)
                         {
                              var builds = products[software];
                              for(build in builds)
                              {
                                   version = builds[build]["version"];
                                   build = builds[build]["build"];
                                   document.write("<p>Build: "+build+", Version: "+version);
                                   document.write("<p>About to make a new option."); // This prints out
                                   selectBox.options[0] = new Option("Test", "text");
                                   //try { selectBox.add(new Option("Test", null)); } catch(e) { selectBox.add(new Option("Test")); }
                                   document.write("<p>Option created."); // This never prints out
                              }
                              break;
                         }
                    }
               }


               function clearList(selectBox)
               {
                    document.write("<p>Entering clearList</p>"); // We get here
                    while( selectBox.length != 0 )
                    {
                         selectBox.options[selectBox.length - 1] = null;
                    }
                    document.write("<p>Exiting clearList</p>"); // We get here
               }
</script>

...

     <body>
          <form name="test" id="test">

               Product:
               <select name="product_id" onChange="showVersions();">
                    <!--<select name="product_id">-->
                    <option label="Aramis" value="2">Aramis</option>
                    <option label="Virtual PLGR" value="3">Virtual PLGR</option>
                    <option label="Sim Radio 2" value="5">Sim Radio 2</option>
                    <option label="Sofia" value="6">Sofia</option>
               </select>
               <br><br>
               Builds: <select id="buildSelect" name="buildSelect"></select>
          </form>
     </body>