title: javascript: dynamic drop down menu values
body: <p>i want to create two drop down form and if i select an item on the first menu the second menu will display corresponding value. for example: if i select "fruit" on the first menu, then the second menu will display "apple", "banana" and so on. it must have values on them so i can insert it into database.</p>
  
  <p>html is as follows:</p>
  
  <pre><code>&lt;select id="firstmenu" name="fruit"&gt;
  &lt;option value="apple"&gt;apple&lt;/option&gt;
  &lt;option value="banana"&gt;banana&lt;/option&gt;
  &lt;/select&gt;
  &lt;br/&gt;
  &lt;select id="secondmenu" name="vegetable"&gt;
  &lt;option value="carrot"&gt;carrot&lt;/option&gt;
  &lt;option value="celery"&gt;celery&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>javascript; i was thinking using something like this but i lack understanding of javascript</p>
  
  <pre><code>&lt;script&gt;
  var a=document.forms["myform"]["fruit"].value;
  var b=document.forms["myform"]["vegetable"].value;
  
  if (a=="fruit")
  {
  ...
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>could someone give me a code example? help is much appreciated, thanks.</p>