Degradable PHP/AJAX forms
March 17, 2006 6:23 AM Subscribe
PHP/AJAX: Say I have a form with 3 SELECT's - country, state/province, city. I'm looking for a something that will update the SELECT's from the server using AJAX if possible, but will also degrade to the non-AJAX version for people that have JavaScript disabled. Can anyone recommend a PHP library that can do that?
Response by poster: It isn't possible to include all the possible values in the HTML/JavaScript, let's say there are 100000 cities. So if JavaScript isn't enabled, it needs fill the form in several stages .
posted by Sharcho at 6:34 AM on March 17, 2006
posted by Sharcho at 6:34 AM on March 17, 2006
Response by poster: empath, I'm looking for something for PHP not ASP.NET, and I think that the solution proposed in the article won't work if JavaScript isn't enabled.
posted by Sharcho at 6:56 AM on March 17, 2006
posted by Sharcho at 6:56 AM on March 17, 2006
I don't see why you'd need a library to do this. Set up the HTML form to only include the Country selector, then use Javascript (if it's enabled) to insert the state/city selector and run the AJAX gubbins. Then in the PHP script that processes the form, check if state (etc) has been chosen, and if not ask the user to choose one then. Very simple.
posted by cillit bang at 7:05 AM on March 17, 2006
posted by cillit bang at 7:05 AM on March 17, 2006
Yeah, you're not going to find a library for such a specific problem. First, create a form that works with no JavaScript (e.g. get city by input rather than select). Then add JavaScript where appropriate (e.g. replace city input with auto-filled select when state is chosen).
posted by scottreynen at 7:41 AM on March 17, 2006
posted by scottreynen at 7:41 AM on March 17, 2006
Response by poster: I found an example for how to do degradable AJAX forms here
posted by Sharcho at 5:43 AM on March 18, 2006
posted by Sharcho at 5:43 AM on March 18, 2006
This thread is closed to new comments.
Just include javascript on the page to select (or limit) the values you want (or want to hide).
posted by orthogonality at 6:29 AM on March 17, 2006