2012-03-20 78 views
0

我有一個正常的形式與國家和城市的組合選擇,當我發送形式沒有問題,但當我回到正確的錯誤形式,我看不到城市我選擇了該頁面並沒有讓我看到選擇的其餘部分。該腳本是:聯合選擇和加載頁面

$(document).ready(function(){ 
    $("#country").change(function(event){ 
     var id = $("#country").find(':selected').val(); 
     $("#city").load('1select.php?id='+id); 
     $("#city").html(options); 
     $('#city option:first').attr('selected', 'selected'); 
    }); 
}); 

我嘗試在Firefox中按Ctrl + Shift + K(我不記得名字了),唯一的錯誤是「沒有定義的jQuery」。我不知道代碼有什麼問題。

+1

後您的html代碼 – DG3 2012-03-20 19:53:54

+0

** 1。**爲什麼您允許提交無效表單?** 2。**當您收到無效的投遞請求時,您給出的頁面是什麼? – gdoron 2012-03-20 19:54:23

回答

0

「,以確保你有你的選擇值的歷史,當你回到你的表格,你可以使用PHP如下(我可以做一些語法錯誤,因爲我不是PHP開發)

<select name="city"> 
    <option value="birmingham" <?php if (isset($_POST['city']) && $_POST['city'] =='birmingham'){ ?>> selected <?php } ?>Birmingham </option> 
</select> 
+0

謝謝,這是非常好的工作:) – dcarolinac 2012-04-18 15:08:48