Help with Drop down lists

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
varun_146100
Forum Newbie
Posts: 3
Joined: Wed Oct 22, 2008 3:48 am

Help with Drop down lists

Post by varun_146100 »

Hi ,

Am a newbie to PHP and have been working with drop down lists.
I have a drop down list with 3 options.
Like i have 3 options available there i.e new/cancel/update.
Now i need to generate another 2-3 drop down lists after selection of either of these options above.
For example if i select update 3 different drop down lists should be generated on the screen.
How should i do this...Please help.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Help with Drop down lists

Post by papa »

...
<select name="first" onchange='this.form.submit()'>
<option value="form1">Form1</option>
<option value="form2">Form2</option>
<option value="form3">Form3</option>
</select>
...

Code: Select all

<?php
$first = $_POST['first'];
if(!empty($_POST['first']) {
 
switch($first) {
case "form1":
echo "select 1";
break;
case "form2":
echo "select 2";
break;
case "form3":
echo "select 3";
break;
}
}
?>
Fast and ugly :)
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Help with Drop down lists

Post by aceconcepts »

If you want to process this via the client-side you could take a look at "chained select menus".

Here's a link: http://www.dynamicdrive.com/dynamicinde ... /index.htm
Post Reply