Load Country/State/City

前端 未结 1 1317
春和景丽
春和景丽 2021-01-07 05:22

I have chain of drop down like Country / state and City. Is there is any way to wait until the drop down population then proceed further? like first load the country and the

相关标签:
1条回答
  • 2021-01-07 05:52

    You may do like this

    $('#cb_country').change(function(){
        var id=$(this).val();
        $.get('getCity.php',{id:id},function(data){
            $("#cb_city").html(data);
        });
    });
    

    getCity.php:

    <?php
    require('../conn.php');
    
    $id=$_GET['id'];
    $Q=mysql_query("SELECT * FROM city WHERE CountryID='".$id."' ORDER BY Cityname ASC");
    
    do{
        echo "<option value='".$row['CityID']."'>".$row['CityName']."</option>";
    }
    while($row=mysql_fetch_assoc($Q));
    
    0 讨论(0)
提交回复
热议问题