/    Sign up×
Community /Pin to ProfileBookmark

Linked Menus with Dynamic Content

Hi,

I know this question has been asked before, because google is littered with links, but they do not seem to have the correct / complete answer.

I run a database with Countries, States and Cities. A person can choose, for accommodation, the country they want to visit, the state, the city, the property.

A am attempting the following:

From 3 drop down lists, you first select the Country ie. South Africa. The second drop down list updates with the result from a database query which lists all the states relevant to that country (Western Cape, Eastern Cape, Gauteng, etc.). If you choose from the second list ie. Western Cape, the 3rd list should update with the results of a query that will list the cities for that state (ie. Cape Town, Bellville, Stellenbosch, etc), you choose Cape Town and can then select accommodation for that relevant list ie. Tableview BandB, Cablecar Hotel, etc.

The structure of the db is simple.
Each country has an id.
Each state has a country id and a state id.
Each city has a state id and a city id.
Each property has a city id and property id.

I can get the results and load them into an array, and if I set the whole page to reload, I can populate the drop down list easily. But my target audience will have slow connections and can’t afford the expense of 3 reloads to get an answer.

Can anyone advise, preferably using php (if this is possible), how to ‘refresh’ just the drop down list without a whole page reload, keeping in mind it will be populate with DYNAMIC content. All the linked-list-info on google tends to work with static, hard coded, preloaded javascript widgets. ?

Your help is infinitely valued.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 06.2005 — You'll probably need to pursue a client-side solution. What I've done in the past is to have the PHP db queries used to populate JavaScript arrays. Then you use JavaScript to update the list for one select when another select is changed. The somewhat ugly part of this is, if there's alot of data involved, it all has to get sent to the browser to populate the Javascript data. But it's all plain text, and doesn't do that much to the download time (at least compared to a large color picture).
×

Success!

Help @TheQuestionIs 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.19,
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,
)...