PHP &

0 Cevap php

Ben bir sorguya ölçüt oluşturmak için kullanılan html çoklu seçim dropdowns bir demet görüntülemek için bir php dosyası "Kriterleri" var.

Çeşitli dropdowns seçilen seçeneklere göre bir SQL deyimi oluşturur bir php dosyası "Sonuçlar", sorgu yürütür ve daha sonra bu sorgunun sonuçlarını görüntüler var.

Ben yeniden & zorunda atlamak istiyorum her yüzlerce seçeneği içeren gibi, her seçin açılan için tüm html yankı. Ajax Bunun için benim çözüm oldu.

Her açılan için, bir Onchange olay benim "Sonuçlar" sayfasına bir Ajax çağrısı yürütür benim javascript çağırır. Bu "Sonuçlar" sayfa sonra $ _POST ['htmlSelectDropdownID'] kullanarak her select açılan değerini almak istiyorum.

Sorun, şimdi Ajax hayata geçirdik, seçeneğini dropdowns seçilen değeri benim Sonuçları dosyasına genelinde gelmiyor ... ve ben sadece HTML yeniden asla çünkü bu kabul edilebilir olduğunu ...

Herkes bu sorunu çözmek için nasıl bir öneriniz var mı?

Teşekkürler,

------------------------ Kod ------------------------- -

Benim Javascript / Ajax

 function AjaxPostback(){
/*if (str=="")
{
    document.getElementById("divTest").innerHTML="";
    return;
} */
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 (xmlhttp.readyState==4)// && xmlhttp.status==200)
    {
        document.getElementById("divResults").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","Results.php", true); //?q="+str,true);
xmlhttp.send();}

Sadece 1 sayfamda açılan bir

Group By <select id="selGroupBy" name="selGroupBy" onchange="AjaxPostback()">
            <option value='Department' <?php if ($_POST['selGroupBy'] == 'Department') echo 'selected="selected"'; ?>>Department</option>
            <option value='Store' <?php if ($_POST['selGroupBy'] == 'Store') echo 'selected="selected"'; ?>>Store</option>
            <option value='Date' <?php if ($_POST['selGroupBy'] == 'Date') echo 'selected="selected"'; ?>>Date</option>
            <option value='Size' <?php if ($_POST['selGroupBy'] == 'Size') echo 'selected="selected"'; ?>>Size</option>
        </select>

-- The html that builds the Criteria (dropdown html) and the div (divResults) who's innerHTML is filled with the javascript

<div>
            <?php include ("Criteria.php"); ?>

            <div class="divResults" id="divResults">
                &nbsp;
            </div>
        </div>

When called, my Results.php file simply checks to document for things like.. if (isset($_POST['selDepartment']) && ($_POST['selDepartment'] == "320 Socks") { $sqlSelect .= $_POST['selDepartment']; }

Ben de .. = \ değerini, aynı sonucu almak yerine $ _POST $ _GET kullanarak denedi

0 Cevap