首先看JQ的扩展如下:
//city selected
jQuery.fn.cityselect = function(n,s1,s2,s3) {
if ((n!=3)&&(n!=2)) {n=2};
if (s1=="") {s1="province"};
if (s2=="") {s2="city"};
if (s3=="") {s3="area"};
if (n==2){//二级联动
//alert(s1+$("select[@name=''"+s1+"''] option[@selected]").val());
$("select[@name=''"+s1+"'']").bind("change",function(event) {
$.ajax({
type: "GET",
url: "/inc/lib/ajax_city.php",
data: "n=v2&cityid="+$("select[@name=''"+s1+"''] option[@selected]").val(),
success: function(opt){$("select[@name=''"+s2+"'']").empty().append(opt);}
});
});
}
if (n==3){//三级联动
$("select[@name=''"+s1+"'']").bind("change",function(event) {
$.ajax({
type: "GET",
url: "/inc/lib/ajax_city.php",
data: "n=v2&cityid="+$("select[@name=''"+s1+"''] option[@selected]").val(),
success: function(opt){
$("select[@name=''"+s2+"'']").empty().append(opt);
$.ajax({
type: "GET",
url: "/inc/lib/ajax_city.php",
data: "n=v3&cityid="+$("select[@name=''"+s2+"''] option[@selected]").val(),
success: function(opt){
$("select[@name=''"+s3+"'']").empty().append(opt);
}
});
}
});
});
$("select[@name=''"+s2+"'']").bind("change",function(event) {
$.ajax({
type: "GET",
url: "/inc/lib/ajax_city.php",
data: "n=v3&cityid="+$("select[@name=''"+s2+"''] option[@selected]").val(),
& |