Dropdown List populated based on the contents of another

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
tinwakr
Forum Newbie
Posts: 2
Joined: Sun Jul 17, 2011 3:07 pm

Dropdown List populated based on the contents of another

Post by tinwakr »

Hi Everyone,

Just a quick question regarding dropdown lists, is it possible, without the use of Javascript and just PHP, to have text fields/dropdown lists, etc. in a form, to be populated based on changing the value of another dropdown list and if so, would someone be kind enough to explain how or point me to information that would show me?

Thanks,
Chuck
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Dropdown List populated based on the contents of another

Post by McInfo »

Yes, but the form would have to be submitted back to the server each time a selection is made.
tinwakr
Forum Newbie
Posts: 2
Joined: Sun Jul 17, 2011 3:07 pm

Re: Dropdown List populated based on the contents of another

Post by tinwakr »

Thanks for the quick reply McInfo,

Would you be able to point me to information such as code examples or a tutorial?

Thanks,
Chuck
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Dropdown List populated based on the contents of another

Post by McInfo »

Basically, it involves using conditional statements to build the form based on what inputs have been received.

I don't know of any specific examples/tutorials, but I'm sure a search engine does.
scular
Forum Newbie
Posts: 3
Joined: Mon Jul 18, 2011 2:27 am

Re: Dropdown List populated based on the contents of another

Post by scular »

I think its not easy to do this without javascript or ajax so dont waste your time its just a wastage of time
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Dropdown List populated based on the contents of another

Post by McInfo »

I don't think it's a waste of time to support users who disable JavaScript.
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Re: Dropdown List populated based on the contents of another

Post by angelicodin »

I'm sure you could use some kind of dynamic xml with php to do some conditional changes with the onChange. ~shrugs~ personally I use java for these types of things but it would be interesting to find out how to get around using java. Like McInfo said, be good for people who don't use java on their browsers.

~following~
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Dropdown List populated based on the contents of another

Post by McInfo »

angelicodin wrote:I use java for these types of things
You mean JavaScript? (JavaScript is not Java.)
Post Reply