rashmi_k28 Posted April 15, 2008 Share Posted April 15, 2008 Hi, here is the code below where the optgroup and list box is common for all the status. Please help me how to display the names based on the status. If I select -- all the names should be displayed and if I select C only few names should be displayed based on the query. <html> <body> <select name='status'> <option value="--">-- <option value="R">R <option value="C">C <option value="S">S <option value="Q">Q </select> </td> </tr> <tr> <td align="left"><label><font color="#006699" face="Arial">Names</font></label></td> <td align="left"><label><font color="#006699" face="Arial">: </font></label></td> <td align="left"> <select name="cluster" onChange="if(this.options[this.selectedIndex].state=='disabled') this.selectedIndex=0"> <option value="--" selected>-- <? $names = Names(); foreach($names as $c){ echo "<option value=\"$c\">$c</option>"; } echo "<optgroup label=\"No Names\">"; $namesdown=disabledNames(); foreach($namesdown as $d){ echo "<option value=\"\" state=\"disabled\" style=\"color:#FF0000;\"><font color=\"#FF0000\">$d</font></option>"; } echo "</optgroup></select>"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/101157-dynamic-list-box/ Share on other sites More sharing options...
Psycho Posted April 15, 2008 Share Posted April 15, 2008 I saw your previous post the other day, and was going to respond. But the fact that you have an option group label in your select list complicates things. Is that really necessary if you are able to repopulate the list? Quote Link to comment https://forums.phpfreaks.com/topic/101157-dynamic-list-box/#findComment-517427 Share on other sites More sharing options...
rashmi_k28 Posted April 15, 2008 Author Share Posted April 15, 2008 No it is not necessary. Quote Link to comment https://forums.phpfreaks.com/topic/101157-dynamic-list-box/#findComment-517428 Share on other sites More sharing options...
Psycho Posted April 15, 2008 Share Posted April 15, 2008 Take a look at my example code in reply #3 in this post: http://www.phpfreaks.com/forums/index.php/topic,192055.new.html#new Quote Link to comment https://forums.phpfreaks.com/topic/101157-dynamic-list-box/#findComment-517998 Share on other sites More sharing options...
rashmi_k28 Posted April 16, 2008 Author Share Posted April 16, 2008 I have to query from the database and list the values in list box based on other list box Quote Link to comment https://forums.phpfreaks.com/topic/101157-dynamic-list-box/#findComment-518189 Share on other sites More sharing options...
Psycho Posted April 16, 2008 Share Posted April 16, 2008 Well, either pull all the values from the DB and populate JS arrays or use AJAX. This is the Javascript forum, so I provided a response using Javascript. Quote Link to comment https://forums.phpfreaks.com/topic/101157-dynamic-list-box/#findComment-518635 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.