ajax php选择misqly country column给city

时间:2017-03-19 18:55:02

标签: php ajax mysqli

当我选择国家/地区时,请将页面重新打开....我不知道解决该问题会再次向我显示相同的数据......

$parentTake = '0';
$judetLista = "";
$stmt = $con->prepare( 'SELECT  id, name, code  FROM account_county ORDER BY name ASC' );
$stmt->execute();
$stmt->store_result();
if( $stmt->num_rows > 0 ){
$stmt->bind_result($idParentJudet, $numeJudet, $numeJudetCod);
    while ($stmt->fetch()){
        $judetLista .= '<option value="'.$idParentJudet.'" >'.$numeJudet.'</option>';
        if(isset($_GET['orase'])){
        $orase = intval($_GET['orase']);
        $localitateLista ='';
        $stmt3 = $con->prepare('SELECT id, name, regiune, parent FROM account_city WHERE parent=? ORDER BY name ASC');
        $stmt3->bind_param('i', $orase);
        $stmt3->execute();
        $stmt3->bind_result($idLista3, $numeLocalitate3, $regiuneLocalitate3, $parentLocalitate3);
         while ($stmt3->fetch()){
                        $localitateLista .=  '<option value="'.$numeLocalitate3.'">'.$numeLocalitate3.'</option>';
                    } //close while 
        $stmt3->close();
        }//close if isset
    } // close while  categorie first select
}
$stmt->free_result();

AJAX

<script>
function showUser(str) {
    if (str == "") {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else { 
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("txtHint").innerHTML = this.responseText;
            }
        };
        xmlhttp.open("GET","confirma-comanda.php?orase="+str,true);
        xmlhttp.send();
    }
}
</script>  

表格选择

<div class="form-group">
                              <h3><label class="col-sm-4 col-sm-4 control-label"><strong><span class="label label-info">JUDET: *</span></strong></label></h3>
                              <div class="col-sm-8">
                                <select class="form-control"   onchange="showUser(this.value)"  name="judet_client" required="required">
                                <option value="">Alege judet</option>
                                    <?php echo $judetLista;?>
                                </select>
                              </div>
                          </div>
                          <div class="form-group " id="txtHint">
                              <h3><label class="col-sm-4 col-sm-4 control-label"><strong><span class="label label-info">LOCALITATE:*</span></strong></label></h3>
                              <div class="col-sm-8" >
                                <select class="form-control" onchange="showUser(this.value)"  name="localitate_client" required="required">
                                    <?php echo $localitateLista;?>
                                </select>
                              </div>
                          </div>   

问题是当我选择一个judet(意思是国家)打开我上面的同一个页面时就像克隆一样...并且给我在cloneting部分的locatitate(意思是城市)...

0 个答案:

没有答案