所以,基本上我有這個選擇/下拉菜單,我使用AJAX檢索和創建,但是當選擇一個選項(so onChange)時,我希望它重定向!AJAX生成的選擇不會重定向
雖然這仍然不起作用,但在嘗試時沒有遇到任何錯誤,並嘗試執行alert()調試方法,但警報沒有被調用。
jQuery的
$("#schoolMenu").change(function() {
option = $("#schoolMenu option:selected").text();
alert(option);
if(option != "- Please Select -") {
window.location = "http://www.itmustbecollege.com/pics/pics-from-"+$("#schoolMenu option:selected").val();
}
});
這就是用來調用AJAX
// // 填充學校 //
$("#state").change(function() {
option = $("#state option:selected").text();
if($(this).attr("class") == "menu") {
if(option != "- Please Select -") {
$.ajax({
type: "GET",
url: "/includes/functions.php",
data: "f=school&p="+option+"&m=yes",
success: function(msg) {
$("#fSchool").html("<p style=\"margin-left: 20px;\">Select School:</p>"+ msg);
$("#fSchool").show();
$("#school").focus();
}
});
}
else {
$("#fSchool").html("");
$("#fSchool").hide();
}
}
else {
if(option != "- Please Select -") {
$.ajax({
type: "GET",
url: "/includes/functions.php",
data: "f=school&p="+option,
success: function(msg) {
$("#fSchool").html(msg);
$("#fSchool").show();
$("#school").focus();
}
});
}
else {
$("#fSchool").html("");
$("#fSchool").hide();
}
}
});
它加載完美,如果你看一下http://www.itmustbecollege.com/quotes/在那裏你可以按照Popular |排序最新|類別|學校
如果你懸停在學校的下拉菜單出現,選擇任何國家和另一個出現,雖然當改變什麼都沒有發生。
這裏是PHP對於第二個下拉
// Get College List
function getCollege($state, $m = "no", $l = "no") {
// Displays Schools
if($m == "yes") {
$options = '<select id="schoolMenu" name="school"><option value="select" selected="selected">- Please Select -</option>';
}
else if($l == "yes" || $l == "yes2") {
$options = '';
}
else {
$options = '<select name="school"><option value="select" selected="selected">- Please Select -</option>';
}
$listArray = split("\|\\\\", $list);
for($i=0; $i < count($listArray); $i++) {
if($m == "yes") {
$options .= '<option value="'. trim(titleReplace($listArray[$i])) .'">'. trim($listArray[$i]) .'</option>';
}
else if($l == "yes") {
$options .= '<li><a href="/quotes/quotes-from-'. titleReplace($listArray[$i]) .'" title="'. trim($listArray[$i]) .' Quotes">'. trim($listArray[$i]) .'</a></li>';
}
else if($l == "yes2") {
$options .= '<li><a href="/pics/pics-from-'. titleReplace($listArray[$i]) .'" title="'. trim($listArray[$i]) .' Pictures">'. trim($listArray[$i]) .'</a></li>';
}
else {
$options .= '<option value="'. trim($listArray[$i]) .'">'. trim($listArray[$i]) .'</option>';
}
}
echo $options .='</select>';
return false;
}
任何幫助將是巨大的!
編輯:另外,我有那些下拉菜單的方式有點奇怪,當你懸停在任何其他「排序」鏈接他們消失,這是「按學校排序」的問題,因爲第一個選擇框顯示列表,如果你去選擇一所學校,然後以某種方式漂浮在它消失的另一個鏈接上,如何延遲或修復那個小問題的任何幫助?
在這種情況下,直播或代表不起作用? – 2011-01-08 06:30:36