开发者

refresh sub category combo box in php?

开发者 https://www.devze.com 2022-12-23 08:28 出处:网络
i need to refresh combo box (sub category ) related to what i choose in main category combo box , for example if i choose \"chicken\" in main category , the value of sub category will be \"grilled chi

i need to refresh combo box (sub category ) related to what i choose in main category combo box , for example if i choose "chicken" in main category , the value of sub category will be "grilled chicken" , " fried chicken " ? how should i do t开发者_运维百科his ?

    <select name="categorylist" id="categorylist">
    <?
    $sql_query= mysql_query("select category_id,category_name, from categories");
    while($fetch= mysql_fetch_array($sql_query)) 
    {   ?>

      <option value= " <? echo "$fetch[category_id];" ?> " selected="selected"><? echo "$fetch[category_name]"; ?> </option>
     <? 
    }
     ?>

what should i put in subcategory ?


This is often refereed to as a "Dependent" or "Dynamic" drop-down. Try a search for that term and you are likely to find a bunch of examples and explanations.

I posted a rather lengthy explanation a while ago, over here:
http://www.dbforums.com/php/1638255-dynamic-drop-down-selection.html

It uses JavaScript though. But even so, if you don't want that, it should at least give you an idea as to where you could start.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号