PDA

Click to See Complete Forum and Search --> : About dropdown combo


saraa
Oct 30th, 2006, 08:53 PM
hi all..please let me know..

I have 2 tables..category(cat_id,cat_code,cat_desc) and item(item_id,item_code,item_desc,cat_code).One category have many items.
There are 2 drop down combos in my form.for category and item.if I select the category, just items under category will listed in item's drop down combo...
Here is my codes:

for category:
<td><select name="cat_code">
<?
$sqlst = mysql_query("SELECT cat_code,cat_desc FROM category ORDER BY cat_desc");
while($cat = mysql_fetch_array($sqlst)){ ?>
<option value="<? echo $cat['cat_code'] ?>"><? echo $cat['cat_desc'] ?>
</option>
<? } ?>
</select></td>

For Item:I dont know how and where to assign a variable for $cat_code
<td><select name="item_code">
<?
$sqlst = mysql_query("SELECT item_code,item_desc FROM item WHERE cat_code='$cat_code'");
while($item = mysql_fetch_array($sqlst)){ ?>
<option value="<? echo $item['item_code'] ?>"><? echo $item['item_desc'] ?>
</option>
<? } ?>
</select></td>

Thnks in advance

kows
Oct 30th, 2006, 09:40 PM
the easiest way would be to load all of your items and use javascript to display only the items you need to given the category. I can't really help you much with the javascript stuff in that situation.

alternatively, and probably less effective/useful, you could have multiple pages for your form, and once a person selects a category, they would press some button titled "next" and then you would select the category you would want. this would require the user to press back, though, to change the category at the last minute.. which is sometimes not desirable.

saraa
Oct 30th, 2006, 10:39 PM
the easiest way would be to load all of your items and use javascript to display only the items you need to given the category. I can't really help you much with the javascript stuff in that situation.

alternatively, and probably less effective/useful, you could have multiple pages for your form, and once a person selects a category, they would press some button titled "next" and then you would select the category you would want. this would require the user to press back, though, to change the category at the last minute.. which is sometimes not desirable.Thanks again...ok let me try it out first..thanks