Continent table
Country table
This is the data in my table, and I get all the data from the continent table and country table, as shown
<select name="continent" class='required InputBox'> <?php echo "<option value=''></option>"; foreach (Contintent() as $value) { echo "<option id='" . $value[ 'sysid'] . "' value='" . $value[ 'name'] . "'>" . $value[ 'name'] . "</option>"; } ?> </select>
This is for the country.
<select name="country" class='required InputBox'> <?php echo "<option value=''></option>"; foreach (Country() as $value) { echo "<option id='" . $value[ 'sysid'] . "' value='" . $value[ 'name'] . "'>" . $value[ 'name'] . "</option>"; } ?> </select>
I want to know how to do this in such a way that when I choose a continent, for example, Asia, the option available for the district will be a country only in Asia, which is Japan and China. I also have another table after that, which is a city, but if I get the logic, I can apply it to the city. Any idea appreciated
"UPDATE"
Found here
That I am not familiar with ajax, can someone try to explain how it works, I want to know how I can pass the select identifier from this javascript fragment to my php functions page, here is a fragment ..
$('.continent').change(function() { var id = $(this).find(':selected')[0].id; //alert(id); $.ajax({ type:'POST', url:'../include/functions.php', data:{'id':id}, success:function(data){ // the next thing you want to do console.log(data); alert(id); } }); });
in my php function
function Country(){ if(isset($_POST['id'])){ echo $_POST['id']; } }
The problem is that the id value is not passed, how to pass it to function.php. This happened in success:function(data){ , what will I do next?
FYI
The warning that it receives the identifier of the continent, it simply is not passed to function.php and console.log does not write anything, and when I change the url to the main page, on the page where select are located in console.log, it returns the code of the main page.