<div id="connect">
</div>function getxx() {
var stype = $("#hitype").val();
var scategory = $("#Category").val();
var parentId = $("#optionreasontype").val();
if (parentId == "0") {
$("#highreasontype").html("<option value=\"0\">请选择</option>");
}
else {
var url = window.SecondCatlog + "/XXXReason/GetXXXXXTypeDDList";
$.getJSON(url, {
category: scategory,
type: stype,
parentId: parentId
}, function (result) {
var str = "";
if (result != null) {
var t = 0
$.each(result, function (k, v) {
if (t == 0) {
str = "<table class=\"connectReason\" style=\"width:100%\"><tr><td colspan=\"4\" style=\"text-align:center;color:green\"><span class=\"chkTransform\"><input type=\"checkbox\" value=\"true\"\ onclick=\"CheckedAllClick()\" id=\"checkAll\" \">全选</span></td></tr><tr>";
}
t++;
if ((t-1)% 4 == 0) {
str += "</tr><tr>";
}
str += "<td style=\"width:25%\"><span class=\"chkTransform\"><input type=\"checkbox\" value=\"" + v.Id + " \" id=\" " + v.Id + " \" name=\"secondreasonname\" \>" + v.ReasonName + "</span></td>";
});
str += "</tr></table>"
}
$("#connect").html(str);
var item = $("#second").val();
$("#highreasontype").val(item);
if (item != 0) {
$("#notfirst").attr("checked", "checked");
$(".orehighreason").show();
}
})
}
}
本文介绍了一种使用JavaScript动态加载下拉菜单选项的方法。通过Ajax获取后台数据,并利用jQuery操作DOM来更新HTML内容,实现了根据不同条件显示相应选项的功能。
2304

被折叠的 条评论
为什么被折叠?



