title: Get id of a selected item from one combo box to another
body: <p>I want to get the category_id of the selected category and pass it to next query of subcategory so the next combo box will contain subcategories according to the selected category. Can you please help me to do it. Here is my javascript, php and html code.</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
    function showCompany(catid) {
        document.form.submit();
    }
  &lt;/script&gt;  
  
  
  
  &lt;select name="cat_id" id="cat_id" onChange="showCompany(this.value);"&gt;
    &lt;option value=""&gt;--Select--&lt;/option&gt;
                         &lt;?php
                          $sql_row1 = mysqli_query($mysqli,"SELECT * from categories");
                         while($sql_res1=mysqli_fetch_array($sql_row1))
                         {
                         ?&gt;
                         &lt;option value="&lt;?php echo $sql_res1["category_id"]; ?&gt;"&gt;&lt;?php echo $sql_res1["category"]; ?&gt;&lt;/option&gt;
                          &lt;?php
                          }
                          ?&gt;
  &lt;/select&gt;
                         &lt;select name="company_id" id="company_id"&gt;
  
             &lt;option value=""&gt;--Select--&lt;/option&gt;
             &lt;?php
             $sql_row = mysqli_query($mysqli,"SELECT * from subcategories where category_id='$_REQUEST[cat_id]'");
  
             while($sql_res=mysqli_fetch_array($sql_row))
             {
             ?&gt;
             &lt;option value="&lt;?php echo $sql_res["subcategory_id"]; ?&gt;"&gt;&lt;?php echo $sql_res["subcategory_name"]; ?&gt;&lt;/option&gt;
             &lt;?php
             }
             ?&gt;
  &lt;/select&gt;
  </code></pre>