dyanmic drop down list (without my_sql)

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
imranali
Forum Newbie
Posts: 3
Joined: Sat Apr 07, 2007 7:52 am

dyanmic drop down list (without my_sql)

Post by imranali »

Hey. What I need to do is, there's a dropdown list. When someone clicks something in the dropdown list, something happens.

for example:
country (field 1)
city (field 2)

If user selects country, city related to selected country should automatically come into city field.

I request to give me a little example here.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're looking for a chained select. This is a client-side functionality, not PHP.

Search through our various boards for the phrase.
imranali
Forum Newbie
Posts: 3
Joined: Sat Apr 07, 2007 7:52 am

dyanmic drop down list (without my_sql)

Post by imranali »

feyd wrote:You're looking for a chained select. This is a client-side functionality, not PHP.

Search through our various boards for the phrase.
Sir, actually my english is also not good so may be not asked corretly.

i can give you a example http://www.bestessays.com/order.php where when you'll select "TYPE OF DOCUMENT", some below fields data will be changed.

like if you'll select THESIS, "COST PER PAGE" will be changed.

can you kindly help me out. sir, i'm tyring for a week but still not got how to do.

pl help me.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

As feyd was saying, this sort of functionality requires javascript.... search these forums for "chained select" or check out google
imranali
Forum Newbie
Posts: 3
Joined: Sat Apr 07, 2007 7:52 am

Post by imranali »

aaronhall wrote:As feyd was saying, this sort of functionality requires javascript.... search these forums for "chained select" or check out google
isn't there any alternate way in PHP?

pl help me out.
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Post by louie35 »

User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

There are two ways of doing this...

1) Reload the page when the first "select" is changed either through javascript or a "find" button.
2) Load all possibilities and handle through javascript
2) Use Ajax (recommended) with fallback option. An example shown in viewtopic.php?t=60287
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Using PHP to do this is simple, but it requires a trip to the server to do it. If you are ok with that, it is nothing more than offering a select list that, when submitted, uses the selected item to query the database and load another select list.
Post Reply