|
-
Oct 30th, 2006, 09:53 PM
#1
Thread Starter
Junior Member
About dropdown combo
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:
PHP Code:
<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
PHP 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
Last edited by saraa; Oct 30th, 2006 at 10:17 PM.
-
Oct 30th, 2006, 10:40 PM
#2
Re: About dropdown combo
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.
-
Oct 30th, 2006, 11:39 PM
#3
Thread Starter
Junior Member
Re: About dropdown combo
 Originally Posted by kows
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|