webguync Posted April 28, 2008 Share Posted April 28, 2008 I have a select menu of states that uses Javascript to autopopulate another select form depending on which state is choses will display cities within that state. I know want to display property results from a MySQL DB so for instance when someone chooses California and Los Angeles and hits submit the property results for that particular city will display. I have city set up as a field in the database and just need some help with the PHP to make this happen. thanks in advance. Quote Link to comment Share on other sites More sharing options...
psychowolvesbane Posted April 28, 2008 Share Posted April 28, 2008 You will need to show your current code to help make this quicker to help with. Quote Link to comment Share on other sites More sharing options...
webguync Posted April 28, 2008 Author Share Posted April 28, 2008 I will just show the code for one state since 50 of them produced a lot of code <table> <tr> <form name="classic"> <select name="countries" size="4" onChange="updatecities(this.selectedIndex)" style="width: 150px"> <option selected>Select A State and City</option> <option value="AL">AL</option> ption> </select> </td> <td> <select name="cities" size="4" style="width: 150px" onClick="alert(this.options[this.options.selectedIndex].value)"> </select> </form> <script type="text/javascript"> var countrieslist=document.classic.countries var citieslist=document.classic.cities var cities=new Array() cities[0]=[""] cities[1]=["Auburn|auburnvalue", function updatecities(selectedcitygroup){ citieslist.options.length=0 if (selectedcitygroup>0){ for (i=0; i<cities[selectedcitygroup].length; i++) citieslist.options[citieslist.options.length]=new Option(cities[selectedcitygroup][i].split("|")[0], cities[selectedcitygroup][i].split("|")[1]) } } </script> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
webguync Posted April 28, 2008 Author Share Posted April 28, 2008 anyone able to help out? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.