ajax question - show diferent forms on dropdown select.

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
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

ajax question - show diferent forms on dropdown select.

Post by pedrotuga »

I have a form that depends on a selection made by the user.

For example, when the user comes he/she can only see a dropdown to choose the continent he/she lives.
Once selected the page should display the rest of the form... like... choosing the country... region, age, profession, etc etc...

this is not the most polite way to ask... but... can somebody post basic code on how to do this?

thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

That is only an Ajax question if the revealed form fields need to load based on the selection. Otherwise it is simple a matter of using Javascript to set elements to be visible based on a selection. The display Javascript is essentially the same whether Ajax is used or not.
(#10850)
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

yep... the fields are based on the content of the form.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

So whether you use Ajax or not depends on whether you want to Lazy Load the data or initialize the page with all the data (you could create Javascript arrays for example). EIther way you do it, the display handling code is the same. And if designed properly, it should not matter where the data comes from so you could switch between Lazy Loaded and initialized data.
(#10850)
Post Reply