title: preload HTML drop down with javascript
body: <p>I wanna preload a dropdown menu with data I get from a Servlet. This is how my code looks like at the moment:</p>
  
  <pre><code>&lt;script&gt;
  var method = ${method};
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
    function PreselectMyItem(value)
    {
      // Get a reference to the drop-down
      var myDropdownList = document.form.select;
  
      // Loop through all the items
      for (iLoop = 0; iLoop&lt; myDropdownList.options.length; iLoop++)
      {    
        if (myDropdownList.options[iLoop].value == value)
        {
          // Item is found. Set its selected property, and exit the loop
          myDropdownList.options[iLoop].selected = true;
          break;
        }
      }
    }
  &lt;/script&gt;
  
  &lt;body onload="init(jsonData); PreselectMyItem(method)"&gt;
  
  &lt;div&gt;
              &lt;div id="header"&gt;
              &lt;form method="post" action="Servlet" id="form" name="form"&gt;
              &lt;table border=0 width=100%&gt;
              &lt;tr&gt;
              &lt;td&gt;&lt;select name="method" id="select"&gt;
                      &lt;option value="AllDocs"&gt;AllDocs&lt;/option&gt;
                      &lt;option value="TermTerm"&gt;TermTerm&lt;/option&gt;
                      &lt;option value="DocsDocs"&gt;DocsDocs&lt;/option&gt;
                  &lt;/select&gt;&lt;/td&gt;
              &lt;/tr&gt;
                      &lt;/table&gt;
               &lt;/form&gt;
               &lt;/div&gt;
  &lt;/div&gt;&lt;/body&gt;
  </code></pre>
  
  <p>The value seems to be transmitted correctly, but it's not selected in the drop down menu.</p>
  
  <pre><code>&lt;script&gt;
  var method = TermTerm;
  &lt;/script&gt;
  </code></pre>