multiple drop down menus

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cholam20
Forum Newbie
Posts: 2
Joined: Thu Oct 14, 2010 1:18 am

multiple drop down menus

Post by cholam20 »

Gurus,

I am a niewbie in php. I have to modify an already existing code.

To populate second drop down menu as per the selected value of first drop down menu. Values of First drop down menu is from a mysql database + php. Now I have to insert a sub category menu in javascript by passing the selected value of the first dropdown.

Pls help.

thanks
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: multiple drop down menus

Post by kalpesh.mahida »

Hi,

Take a look at Simple chained combobox jQuery plugin at http://www.codeassembly.com/Simple-chai ... or-jQuery/

Hope this will help you,

Kalpesh Mahida
cholam20
Forum Newbie
Posts: 2
Joined: Thu Oct 14, 2010 1:18 am

Re: multiple drop down menus

Post by cholam20 »

Please help me how to proceed after this code.

<td>
<select name="topicId">
<option value="" selected >Select One</option>
<?
$services= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1 ORDER BY topic');
if($services && db_num_rows($services)) {
while (list($topicId,$topic) = db_fetch_row($services)){
$selected = ($info['topicId']==$topicId)?'selected':''; ?>
<option value="<?=$topicId?>"<?=$selected?>><?=$topic?></option>
<?
}
}else{?>
<option value="0" >General Inquiry</option>
<?}?>
</select>
&nbsp;<font class="error">*&nbsp;<?=$errors['topicId']?></font>
</td>
</tr>
After this as per the value selected in the above drop down menu, a javascript shld be written such a way that the next menu values depend on the first menu.
There are only 2 values in the first menu and hence with if condition it may be written in javascript.

Pls help how to proceed.

regds
Post Reply