ajax 级联下拉框
/*---------------------省市区----------------------------*/functionGetProvince(){$.ajax(...
/*---------------------省市区----------------------------*/
function GetProvince() {
$.ajax({
type: "post",
async: false,
url: "Ajax/MasterAjax.ashx",
data: "method=GetProvince",
dataType: "json",
success: function(data) {
var html = "";
if (data != 0) {
var temp = eval(data);
for (var i = 0; i < temp.length; i++) {
html += "<option value='" + temp[i].code + "'>" + temp[i].name + "</option>";
}
}
else {
html = "<option>网络异常</option>";
}
$("#accountprovince").html(html);
$("#residenceprovince").html(html);
}
});
}
//获得市provinceId-省外键,SelectId-给那个下拉菜单赋值
function GetCity(provinceId, SelectId) {
$.ajax({
type: "post",
async: false,
url: "Ajax/MasterAjax.ashx",
data: "method=GetCity&province=" + provinceId,
dataType: "json",
success: function(data) {
var html = "";
if (data != 0) {
var temp = eval(data);
for (var i = 0; i < temp.length; i++) {
html += "<option value='" + temp[i].code + "'>" + temp[i].name + "</option>";
}
}
else {
html = "<option>数据异常</option>";
}
$("#" + SelectId).html(html);
}
});
}
怎么能让他显示出来的值不是第1个 而是我想要的那个值
如何让那个selectid的值等于第17个的值 展开
function GetProvince() {
$.ajax({
type: "post",
async: false,
url: "Ajax/MasterAjax.ashx",
data: "method=GetProvince",
dataType: "json",
success: function(data) {
var html = "";
if (data != 0) {
var temp = eval(data);
for (var i = 0; i < temp.length; i++) {
html += "<option value='" + temp[i].code + "'>" + temp[i].name + "</option>";
}
}
else {
html = "<option>网络异常</option>";
}
$("#accountprovince").html(html);
$("#residenceprovince").html(html);
}
});
}
//获得市provinceId-省外键,SelectId-给那个下拉菜单赋值
function GetCity(provinceId, SelectId) {
$.ajax({
type: "post",
async: false,
url: "Ajax/MasterAjax.ashx",
data: "method=GetCity&province=" + provinceId,
dataType: "json",
success: function(data) {
var html = "";
if (data != 0) {
var temp = eval(data);
for (var i = 0; i < temp.length; i++) {
html += "<option value='" + temp[i].code + "'>" + temp[i].name + "</option>";
}
}
else {
html = "<option>数据异常</option>";
}
$("#" + SelectId).html(html);
}
});
}
怎么能让他显示出来的值不是第1个 而是我想要的那个值
如何让那个selectid的值等于第17个的值 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询