Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.50 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-27-2010, 06:08 AM   PM User | #1
connollyc4
New Coder

 
Join Date: Mar 2010
Location: New Jersey USA
Posts: 74
Thanks: 11
Thanked 4 Times in 4 Posts
connollyc4 is an unknown quantity at this point
Question Chained drop down menu using PHP

I am trying to create 2 different drop down menus which are chained.

First drop down menu: options 1, 2, 3, and 4

Second drop down menu: options 1, 2, 3 and 4

However for the first drop down menu, if you choose the number then that number cannot be selected again on the second drop down menu. So if i pick 4 on the first drop down. then only 1, 2, and 3 should show up on the second drop down OR if you pick 4 on the second drop down it gives you an error saying you selected that value.

Here is the complicated part that I cannot figure out.

I want each drop down menus on two different pages and not on the same page. So after you select the submit button on the first drop down it should go to another page with the second drop down.. Has anyone seen this before. if you can give me some tips or show me how its done or even a webpage that has already implemented this i would appreciate it.

Thank you!
connollyc4 is offline   Reply With Quote
Old 03-27-2010, 08:19 AM   PM User | #2
DaiLaughing
Regular Coder

 
Join Date: Jul 2009
Posts: 136
Thanks: 0
Thanked 7 Times in 7 Posts
DaiLaughing is an unknown quantity at this point
Forgetting the dropdown side for now...

The key is to get the data from the first page to the page with the second dropdown. If you can do that skip the next two paragraphs!

The data from the first page is presumably passed to another page (or itself for processing). You could store that data in a session variable or cookie for use on the page with the second drop down.

If the first page leads directly to the second then the second can access that data using $_POST or $_GET.

Once the data is on the second page PHP can change the dropdown before the page is sent. For example you could create the dropdown using a loop to create each OPTIOON element. In that loop only write the new OPTION if the number does not match the data which came from the previous page. Then the user will not even be able to see the number they already picked.
DaiLaughing is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:56 AM.


Advertisement
Log in to turn off these ads.