Show/ hide dynamic combobox
<p>I have two comboboxes which are generated by queries from mysql.</p>

<p>When user choose value in first combobox i need to display second combobox, but if nothing is choosen second combox should not be displayed.
The code:</p>

<pre><code>&lt;?php
echo "&lt;form method= \"post\" name=\"formcombo\" action=''&gt;";
echo "&lt;select name='cat' onchange=\"reload(this.form)\"&gt;&lt;option value=''&gt;Choose main category&lt;/option&gt;";
while($cat2 = mysql_fetch_array($query2)) {
if($cat2['category_id']==@$category)
{
echo "&lt;option value='$cat2[category_id]'&gt;$cat2[category_name]&lt;/option&gt;&lt;/br&gt;";}
else
{
 echo "&lt;option value='$cat2[category_id]'&gt;$cat2[category_name]&lt;/option&gt;";
}
}
 echo "&lt;/select&gt;&lt;/br&gt;";
 echo "&lt;select name='subcat'&gt;&lt;option value=''&gt;Choose subcategory&lt;/option&gt;";
 while($cat = mysql_fetch_array($query1)) {
 echo "&lt;option value='$cat[subcat_name]'"&gt;$cat[subcat_name]&lt;/option&gt;";
   }
echo "&lt;/select&gt;";
echo "&lt;input type=\"submit\" value =\"Submit\"&gt;";
echo "&lt;/form&gt;";
 ?&gt;
</code></pre>

<p>I use javascript to generate combobox values:</p>

<pre><code>&lt;script type="text/javascript"&gt;
function reload(form){
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='main.php?cat=' + val ;
}
&lt;/script&gt;
</code></pre>
