Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32058

help populate third combobox using php/mysql & javascript

$
0
0
hey comrades, kindly anyone help me to populate the third combobox using the previously discussed double population of 2 related combobox.
below is the code that i got from here which populates 2 comboxes. i edited it to suit my preference but i need to populate the third one. am not soo good in php programing but am trying my level best to be.
please help and give me the code to add the third combobox to populate records accoriding to the selected one in the second combobox. thanks


<script language="javascript"type="text/javascript">
    function showCompany(catid) {
        document.sellform.submit();
    }
</script>



 <tr>
    <td width="119">Item Category</td>
    <td width="371">
    <select name="cat_id" id="cat_id1" onChange="showCompany(this.value);">
       
<option value="">--Select--</option>
       <?php
       $sql1="select * from items group by item_category";
       $sql_row1=mysql_query($sql1);
       while($sql_res1=mysql_fetch_assoc($sql_row1))
       { ?>
       <option value="<?php echo $sql_res1["item_category"]; ?>" 
  <?php if($sql_res1["item_category"]==$_REQUEST["cat_id"]) { echo"Selected"; } ?>>
  <?php echo $sql_res1["item_category"]; ?></option>

        <?php
        }
        ?>
       </select>
       </td>
  </tr>
  
  
    <tr>
    <td>Subcategory-1</td>
    <td id="td_company">
       <select name="company_id" id="company_id">
  
       <option value="">--Select--</option>
       <?php
       $sql="select * from items where item_category='".$_REQUEST['cat_id']."' GROUP BY item_subcategory ";
       $sql_row=mysql_query($sql);
       while($sql_res=mysql_fetch_assoc($sql_row))
       {
       ?>
       <option value="<?php echo $sql_res["item_subcategory"]; ?>"
       
         <?php if($sql_res["item_category"]==$_REQUEST["cat_id1"]) { echo"Selected"; } ?> >  
<?php echo $sql_res["item_subcategory"]; ?></option>
       <?php
       }
       ?>
    </select>
       </td>
  </tr>

here is the third combobox that i tried to make from the above two:



 <tr>
    <td>Subcategory-2</td>
    <td id="td_company">
       <select name="company_id" id="company_id">
  
       <option value="">--Select--</option>
       <?php
       $sql2="select * from items where item_subcategory='".$_REQUEST['cat_id']."' GROUP BY item_sub_subcategory ";
       $sql_row2=mysql_query($sql2);
       while($sql_res2=mysql_fetch_assoc($sql_row2))
       {
       ?>
       <option value="<?php echo $sql_res2["item_sub_subcategory"]; ?>"
       
         <?php if($sql_res2["item_subcategory"]==$_REQUEST["cat_id"]) { echo"Selected"; } ?> >  
<?php echo $sql_res2["item_sub_subcategory"]; ?></option>
       <?php
       }
       ?>
    </select>
       </td>
  </tr>

Viewing all articles
Browse latest Browse all 32058

Trending Articles