JavaScript - How do I pull rows from mysql with Javascript onchange function

Asked By Olusegun A. on 20-Nov-12 10:27 AM
Hello there,

I have a website where info of registered member from various countries and states are collected. On my search form, I have 3 fields; Country, State and Sex. I listed all the countries of the world in my search (as a dropdown), but the state field is empty. Want i want is that once a visitor select a country, i want only the states of that country which registered members have are in my database to be pulled into the state field, instead of all the state of that country.

Eg 3 members from USA are from New York, New Jersey and Georgia. On selecting USA in the country dropdown, only these 3 state should appear under the state insteadt of the 50 states in america.
Pls help.

Thanks
adsegzy
Robbe Morris replied to Olusegun A. on 20-Nov-12 11:22 AM
You will have to set up a server side http handler to accept requests from JavaScript.  JavaScript cannot access MySql (or any other server side database) directly.  So, you'd have a server side page (asp.net or php I guess) that would connect to the database and return html/json to your JavaScript call over XmlHttpRequest.
Olusegun A. replied to Robbe Morris on 21-Nov-12 05:14 AM

Thanks Robbe,

I know how to setup php to pull out data from the database, but my problem it how toreturn html/json to your JavaScript call over XmlHttpRequest. Pls do you have

Thanks