Hi…
Can anyone help me how to synchronize the two dropdown field…
Example:
I have two tables 1 for the Category other for SubCategory.
The output should be, if i have a field for Category.
CatID CatName
1 Door
2 Window
and for SubCategory
CatID SubCatName
1 Knob
1 Lock
2 Glass
2 Lock
Now how do i synchronize it in the dropdown field base on the CatID.
Thanks…
Cups
May 9, 2011, 7:40am
2
[google]linked|chained select boxes[/google]
Hi,
Can anyone help me how to populate the dropdownlist and get the id of the data.
this is my script.it works just fine if i delete the hidden text but i need the hidden text to pass the variable of the said data…Thanks…
<table>
<form action='catsubsamp.php' method='post'>
<tr>
<td align='right'><b>Category<font color=red>*</font>: </b></td>
<td>
<?php
echo "<select class='user' name='user' tabindex='1'>";
echo "<option></option>";
while($user1=mssql_fetch_array($catname)){
echo "<option value='$user1[CatName]'>".$user1['CatName']."</option>";
echo "<input type='hidden' value='$user1[Catid]' name='catidname'>";
}
echo '</select>';
?>
</td>
</tr>
<tr>
<td><b>Sub-Category</b></td>
<td>
<input type='text' name='cat'>
</td>
</tr>
<tr>
<td>
<input type='submit' name='save' value='Save'>
</td>
</tr>
</form>
</table>
thanks for the linked…it is applicable if i just choose the ID of the said Category for the subcategory…i’m just confused…Thanks
Cups
May 9, 2011, 10:21am
5
It looks as if you are asking how to do a join on two tables, but as I am not 100% what you mean - show us the output of these 2 sql queries;
describe category;
describe subcategory;
zbing
May 9, 2011, 10:22am
6
<? echo "<option value=\\"" . $user1['CatId'] . "\\">" . $user1['CatName'] . "</option>"; ?>
Cups
May 9, 2011, 10:26am
7
while($user1=mssql_fetch_array($catname)){
echo "<option value='" . $user1['Catid'] . "'>" . $user1['CatName']. "</option>" . PHP_EOL ;
}
If you are using auto-generated id numbers as Private Keys on a table, one generally passes the id of the chosen cat as the returned value of a select, as indicated above.