<form id="content">
<%
if ("OPCODE".equals(dicType)) {
%>
<div id="opCodeCompent"></div>
<%
} else if ("CHANNEL".equals(dicType)) {
%>
<div id="channelCompent"></div>
<%
} else if ("CITY".equals(dicType)) {
%>
<div id="cityCompent"></div>
<%
} else {
%>
<%
}
%>
</form>
<script type="text/javascript">
var dicType = "<%=dicType%>";
var elementType = "<%=elementType%>";
if ("OPCODE" == dicType) {
var loadUrl = "/special/anHui/loadSysConfList.action?queryMap.DIC_TYPE=" + dicType;
$.get(loadUrl, function (result) {
var elementType = "<%=elementType%>";
var elementHtml = "";
$.each(result, function (_inx, _dic) {
if ("checkbox" == elementType) {
elementHtml = "";
elementHtml = "<input type=\"checkbox\" id=\"opCode_" + _dic.DIC_ID + "\" value=\"" + _dic.DIC_ID + "\" />" + _dic.DIC_NAME;
$("#opCodeCompent").append(elementHtml);
}
else if ("select" == elementType) {
elementHtml = elementHtml + "\n <option value=" + _dic.DIC_ID + ">" + _dic.DIC_NAME + "</option> ";
if (_inx == result.length - 1) {
elementHtml = "<select id=\"opCode_\" name=\"queryMap.opCode\" >" + elementHtml + "\n </select>";
$("#opCodeCompent").append(elementHtml);
}
} else {
$("#opCodeCompent").append("");
}
});
});
} else if ("CHANNEL" == dicType) {
var loadUrl = "/special/anHui/loadSysConfList.action?queryMap.DIC_TYPE=" + dicType;
$.get(loadUrl, function (result) {
var elementType = "<%=elementType%>";
var elementHtml = "";
$.each(result, function (_inx, _dic) {
if ("checkbox" == elementType) {
var innserHtmlValue = "<input type=\"checkbox\" id=\"channel_" + _dic.DIC_ID + "\" value=\"" + _dic.DIC_ID + "\" />" + _dic.DIC_NAME;
$("#channelCompent").append(innserHtmlValue);
} else if ("select" == elementType) {
elementHtml = elementHtml + "\n <option value=" + _dic.DIC_ID + ">" + _dic.DIC_NAME + "</option> ";
if (_inx == result.length - 1) {
elementHtml = "<select id=\"channel\" name=\"queryMap.channel\" >" + elementHtml + "\n </select>";
$("#channelCompent").append(elementHtml);
}
} else {
$("#channelCompent").append("");
}
});
});
} else if ("CITY" == dicType) {
var loadUrl = "/special/anHui/loadSysConfList.action?queryMap.DIC_TYPE=" + dicType;
$.get(loadUrl, function (result) {
var elementType = "<%=elementType%>";
var elementHtml = "";
var rowCount = 0;
$.each(result, function (_inx, _dic) {
if ("checkbox" == elementType) {
rowCount++;
if (_inx == 0) {
var topElement = "<input type=\"checkbox\" id=\"cityAll\" value=\"all\" />全部<p>";
$("#cityCompent").append(topElement);
}
if (rowCount % 5 == 0) {
var innserHtmlValue = "<input type=\"checkbox\" id=\"city_" + _dic.DIC_ID + "\" value=\"" + _dic.DIC_ID + "\" />" + _dic.DIC_NAME + "<p>";
$("#cityCompent").append(innserHtmlValue);
} else {
var innserHtmlValue = "<input type=\"checkbox\" id=\"city_" + _dic.DIC_ID + "\" value=\"" + _dic.DIC_ID + "\" />" + _dic.DIC_NAME;
$("#cityCompent").append(innserHtmlValue);
}
} else if ("select" == elementType) {
elementHtml = elementHtml + "\n <option value=" + _dic.DIC_ID + ">" + _dic.DIC_NAME + "</option> ";
if (_inx == result.length - 1) {
elementHtml = "<select id=\"opCode_\" name=\"queryMap.cityItem\" >" + elementHtml + "\n </select>";
$("#cityCompent").append(elementHtml);
}
} else {
$("#cityCompent").append("");
}
});
});
} else {
$("#partCompent").append("");
}
</script>
原文:http://my.oschina.net/u/1586698/blog/346349