title: javascript function to add to pulldown menu
body: <p>Okay, say I have this pulldown menu that looks like this:</p>
  
  <pre><code>  &lt;form action="" method="POST" name="myform"&gt;
              &lt;select name="test_select"&gt;
                  &lt;option value="1"&gt;my val 1&lt;/option&gt;
                  &lt;option value="3"&gt;my val 3&lt;/option&gt;
                  &lt;option value="4"&gt;my val 4&lt;/option&gt;
              &lt;/select&gt;
              &lt;input type="submit" value="test_button" name="test_button"&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>Just a basic menu. How can I search through and add a value 2 to the menu with a function? I want it to end up looking like this:</p>
  
  <pre><code> &lt;form action="" method="POST" name="myform"&gt;
                  &lt;select name="test_select"&gt;
                      &lt;option value="1"&gt;my val 1&lt;/option&gt;
                      &lt;option value="2"&gt;my val 2&lt;/option&gt;
                      &lt;option value="3"&gt;my val 3&lt;/option&gt;
                      &lt;option value="4"&gt;my val 4&lt;/option&gt;
                  &lt;/select&gt;
                  &lt;input type="submit" value="test_button" name="test_button"&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>I tried making a function, to show where I am trying to go with this.</p>
  
  <pre><code>&lt;script&gt;
          function addItems()
          {
              var option = document.createElement("option");
  
              option.text = "val 2"
              option.value = 2
  
              for (var i = 1; i &lt; 3; i++; ) {
                  if (document.getElementsByName.value &lt; 2) {
                      option.text = "val 2"
                      option.value = 2
                  }
              }
  
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>How do I make this function work?</p>