How do I pull rows from mysql with Javascript onchange

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

How do I pull rows from mysql with Javascript onchange

Post by adsegzy »

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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do I pull rows from mysql with Javascript onchange

Post by requinix »

So does this mean you already have something that will populate the list with the 50 states? You just want to add a "only states with at least one member" restriction to the "states in the selected country" one already on that list?

Also some advice: don't hide choices that won't return results. Leave them there and let users decide what to do. Because it's more confusing to someone to not find Florida in the list of states when they know damn well that Florida so totally is a state in the US. If you want to give them hints then you can modify the list to include the number of members, like showing "New York (1)" and "Florida (0)", or by graying-out the ones without members.
Post Reply