Before diving into code, I’m looking for some good suggestions on how I might go about passing a selected option from a select box to a different php file and then running a specific mySQL query based on the passed option (which option the user selects). Any ideas?
Share
Here is the simplest example to jquery ajax.
Let you aim is to get the cities in a country on select of a country from selectbox, and display the result in a div.
HTML
let this is your selectbox.
< select name=”country” id=”country”>
< option value=”1″>Country1< /option>
< option value=”2″>Country2< /option>
< /select>
Div to display result
< div id=”city”>< /div>
You should correct the spaces in html code, I put spaces in tags because stackoverflow not showing html code (or I don’t know how to put).
Jquery
PHP
file >> ajax.php