Get value from select with JavaScript for use in PHP
<p>I have this <code>select</code>:</p>

<pre><code>&lt;select id="mymenu" name="id" onchange="getID()"&gt;
    &lt;option&gt;&lt;/option&gt;
    &lt;option value="1"&gt;A&lt;/option&gt;
    &lt;option value="2"&gt;B&lt;/option&gt;
    &lt;option value="3"&gt;C&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>I want to get the value from <code>mymenu</code> to use it in another <code>select</code> in the same form. I searched the 'net and found that I should use <code>onchange</code>.</p>

<pre><code>&lt;select name="uid"&gt;
    &lt;option&gt;&lt;/option&gt;
&lt;?
$sql = mysql_query("Select * from $table WHERE id = '$ch_id'");
while ($row = mysql_fetch_array($sql)) {
?&gt;
    &lt;option value="&lt;? echo $row['unit_id']; ?&gt;"&gt;&lt;? echo $row['unit_name'];?&gt;&lt;/option&gt;
&lt;?
}
?&gt;
&lt;/select&gt;
</code></pre>

<p>This is the getID() function:</p>

<pre><code>&lt;script type="text/javascript"&gt;
function getChapterID(){ //run some code when "onchange" event fires
var selectmenu=document.getElementById("mymenu")
&lt;?$ch_id?&gt; = this.options[this.selectedIndex].value
}
&lt;/script&gt;
</code></pre>
