/    Sign up×
Community /Pin to ProfileBookmark

Linked Combos PHP AJAX

Hi,

I am in a need to have to linked Combos (Selects) for State and City, so that when State is changed, City list gets populated from cities of selected database.

I think this can be done via AJAX, and did seach, couldnt find a PHP solution. State, City values are fetched from DB.

If anyone could please guide me on this, it would be a great help.

Thanks and Best Regards

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@ratcatemeOct 21.2008 — do you have any experience with ajax?

i would recommend looking at the [url=http://xajaxproject.org/]xajax project[/url] it has a easy way to implement ajax with limited javascript/ajax knowledge.

Scott.
Copy linkTweet thisAlerts:
@dbrandonOct 22.2008 — This is a hard question to answer because it depends on the ajax solution you are going to use. But the most simple solution...

On the State dropdown you will have a JavaScript onChange event, which will trigger your ajax call to the php page.

The php page should read from the database and echo out all the code for the city dropdown.

Then when the ajax call has completed, you will update the innerHTML of a div (for example) which will be filled with the dropdown code that php generated you.

It is very hard to describe a complete solution, but if you have any specific questions, i'm sure someone can help!
Copy linkTweet thisAlerts:
@SyCoOct 22.2008 — I'm with ratcateme xajax is a very easy way for PHP coder to get into xajax. Their forum is slow but the few who post are very knowledgeable. Look for users BBC, Ed robinsion, Jared,Q_no to name a few.
Copy linkTweet thisAlerts:
@ariellOct 23.2008 — From my point of view, dbrandon came up with a straightforward approach. Before digging yourself into (who knows?) error-prone "version-zero-point-somewhat-so-called-class-code", you should GRAB the problem.

Exactly as brandon put it - JS onchanges that trigger a db-retrieval, and you're done. One must not forget, that "AJAX" (which just means asynchronous javascript and XML) does nothing else. Nowadays, it just SOUNDS better.

If u need help on how to connect JS events, there's lots of (good) explanations in this forum's JS sections. If u need help on how to update the PHP, just re-post.

Best from the south.
Copy linkTweet thisAlerts:
@SyCoOct 23.2008 — Ariel, just to put you straight, xajax 0.24, 0.25 and 0.5 are all stable. The pre release nature of its serializeation is for features not stability or security.

And xajax is more than ajax, it's a PHP class for implementing ajax. You need only very basic javascript to implement complex ajax solutions. We've used it commercially for a couple of years. It's excellent and simple to use, compared to vanilla ajax. So it does more than 'sound better' it brings ajax to PHP coders whose javascript skills are poor.

"Exactly as brandon put it - JS onchanges that trigger a db-retrieval, and you're done."[/QUOTE]

Yes xajax can do that of course, just with far less ajax/javascript knowledge. If you're already cooking with ajax then good for you, you wont need it. But lots of people could benefit from the project so please don't say it is no good when you clearly know nothing about it.

And 'who knows'? well the people at the xajax project can tell you all you could want to know.
Copy linkTweet thisAlerts:
@SyCoOct 23.2008 — If you want to use xajax, there's a tutorial on the xajax site.

http://xajaxproject.org/docs.php

Do the 10 minute tutorial, then the processing form tutorial and you should be good to go. The problem most people encounter is setting the paths to the included files during page set up, so just watch that.

Once you have the page set up the rest is easy, post in this thread or PM me.
Copy linkTweet thisAlerts:
@GUIRauthorOct 23.2008 — Hi Syco,

Thanks for your advices, I'll check and will come back..
Copy linkTweet thisAlerts:
@ariellOct 23.2008 — But lots of people could benefit from the project so please don't say it is no good when you clearly know nothing about it.[/QUOTE]

You should read what I write (if any) more precise: "Before digging yourself into (who knows?) error-prone "version-zero-point-somewhat-so-called-class-code", you should GRAB the problem."

I keep on sticking with that. If "whoever" does NOT "yet cook" with AJAX then it's time to at least learning it. I am NOT saying, that everybody should USE it. But anybody who's doing coding for the web should definitely know what it means and how to handle it, which is clearly preferable to relying on things that I a) do not know and thus b) do not understand.

Last but not least I seriously doubt that you COULD have an idea what I know about xajax. One more "in-precision ". I, too, did not say it was error prone, but trying to see it from the point of view of somebody who clearly didn't handle one or the other.

Listen, if this is some personal stuff, which I somewhat feel it to be, if you're eager to tell me what you think or getting rid of an opinion, write me a message. I don't think that this board is the right place for it in EITHER way.
Copy linkTweet thisAlerts:
@SyCoOct 23.2008 — "Before digging yourself into (who knows?) error-prone "version-zero-point-somewhat-so-called-class-code", you should GRAB the problem."[/QUOTE]
I did read it and as I said either ajax or xajax will solve (grab) the problem equally, what with then being the same thing and all. Xajax is just easier if you're not a proficient javascript coder or have no ajax experienced but can code PHP reasonably well.

I, too, did not say it was error prone,
[/QUOTE]

lol, no course you didn't. And George Bush never said there were weapons of mass destruction in Iraq either. heh.
If "whoever" does NOT "yet cook" with AJAX then it's time to at least learning it.[/QUOTE]
Or use xajax and get on with coding.
I seriously doubt that you COULD have an idea what I know about xajax.[/QUOTE]
Before digging yourself into (who knows?)... [/QUOTE]
That would imply, not you.

or getting rid of an opinion, write me a message.[/QUOTE]
No not trying to get rid of an opinion but if I feel your advice is incorrect or misleading then I will post something here so it can be evaluated by anyone reading the forum. I'm sorry you feel it's personal, it isn't I've just noticed a lot of posts from you that I feel need further comment or correction. If you feel I'm incorrect or can share an opinion about a post I make then by all means post your comments. That's fine, I come here to learn.
×

Success!

Help @GUIR spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...