Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

completing forms on the fly w/out refreshing the page

Status
Not open for further replies.

harglefargle

Technical User
Jul 3, 2007
3
US
Ok, I know this can be done in JavaScript, which is fine if you have a small form or a limited number of options. But I recently saw a site that did this in php and I can't figure out how they pulled it off. Let's say you have a form that has 3 list boxes based on automotive choices. When the page first loads the first box is populated with broad options "Suv, Car, Truck" you get the idea. The next two boxes would be blank at that point. Now, let's say that you choose "Car" from the first box. Normally this would need to be submitted and the page would have to reload before the second box could be populated as the various types of cars are stored in a database. But on this site I saw the second box populates automatically without refreshing the page. Again, easy enough in JS but I had never seen it before using PHP. Likewise, when an option is selected from the now populated second list box the third box populates automatically. I guess what I'm wondering is how in the heck they managed to submit the selection to a php script and have it populate the next box w/out refreshing the page. All I can really tell is that they use the options in the list boxes as links to a php script and pass variables to the script based on the option selected. In my mind at least that would require a submission and as such a refresh. Someone educate me please.
 
they probably did it with javascript but instead of pre-loading the contents of each select box into the first page refresh, they will use xmlhttpobjects (AJAX) to interact with a php server.

this is trivial to achieve but you are better placed asking the question in the javascript forum.

 
Hi, you can search on google:
+ajax +php +select

The first one I found:

That one is not very dynamic, but you get the point..
You can also try to add:
+ajax +php +select +chained

I would recommend you to check out the different ajax toolkits and check out theire examples.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top