I need help populating a list box called 'SubCategory' with results from a db query. The list box should only have results that apply to the first select box called 'Category'. In short this is how I would like to do it but I don't have the technical prowess to complete the JavaScript programming part of it.
//DB QUERY 1 for Categories to populate select box named 'Category'
//DB QUERY 2 for SubCategories to later populate the JavaScript array below to be accessed later by a function in an onChange (or equivalent) JavaScript call attached to the first select box(Category).
=>NEED HELP HERE<=
//JavaScript array with values from DB Query 2(fields: CategoryID, SubCategoryID, SubCatDesc)
//JavaScript function
=>NEED HELP, DON'T KNOW HOW TO DO IT<=
//FIRST SELECT BOX
<select name="Category" onChange="java script:UpdateSubCat(this.value);">
<option selected>Select One</option>
<?php
$i=1; //initliaze a counter
while ($rows=mysql_fetch_array($result1)){
//assign the data to some variables - not really needed but clearer when coding
$catid= $rows['CategoryID']; $catdesc=$rows['CategoryDes
c'];
echo "<option value=" . $catid . >" . $catdesc . "</option>";
$i++; //increment the counter
} //close the while loop
?>
</select>
//END SELECT #1
<select name="SubCategory">
//DON"T KNOW HOW TO POPULATE THIS
</select>
Please help in any way possible. I know there are many ways to do this but this is the way I want to approach it.
Thanks in advance for all of your help
Joe