php - Change drop down list values when another user makes a choice from another drop down list in the same form -


my question is: how can change options-values 1 list according user choose drop down list. issue here these both lists must populated query.

<label for="category"></label>           <select name="category" id="category">           <option value="0" >choose category</option>   <?php foreach(categories::find_all() $id) :?>         <?php echo "<option value=".$id->id .">". $id->cat_name."</option>"; ?>         <?php endforeach?> 

<label for="sub_category"></label>           <select name="sub_category" id="sub_category">           <option value="0" >choose sub category</option>    <?php foreach(categories_sub::find_by_cat_id(????) $id) :?>     <?php echo "<option value=".$id->id .">". $id->cat_sub_name."</option>"; ?>     <?php endforeach?> 

i in 1 of following ways, both involve javascript:

1. when first select box value changes, load second select box ajax (remove current second select box).

2. print out select boxes. show , hide right select box javascript. not involve ajax, need check first select box php check second select box should handled.

i advise framework jquery 1 of these 2 options.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -