前端之家收集整理的这篇文章主要介绍了
ajax 动态级联,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@RequestMapping(value="/modifytable")
public String modifytable(ModelMap model,BzDmb bzDmb,HttpServletRequest request,HttpServletResponse response) {
//model.addAttribute("bzDmb",bzDmb);
//语境列表
List<DmYjdmb> dmYjdmbList = dmYjdmbManager.queryDmYjdmbList();
request.setAttribute("dmYjdmbList",dmYjdmbList);
return "/bzdmb/modify";
}
/**根据业务分类列出表*/
@RequestMapping(value="/bmlist/{ywflDm}")
public void bmListByYwfldm(ModelMap model,@PathVariable java.lang.String ywflDm,HttpServletResponse response) {
String theYwflDm = ywflDm==null?"":ywflDm.trim();
List<BzDmb> bmList = bzDmbManager.queryDmbByYwflDm(theYwflDm);
String content = JSONArray.fromObject(bmList).toString();
super.ajaxOut(content,response);
}
<TABLE width="100%" align=center>
<TR>
<TD >
<TABLE align=center>
<TBODY>
<TR>
<TD>业务分类 : </TD>
<TD>
<select id="ywflDm" name="ywflDm" style="width: 160px">
<option value="">
请选择
</option>
<c:forEach items="${dmYjdmbList}" var="obj">
<option value="${obj.yjDm }" >
${obj.yjMc}
</option>
</c:forEach>
</select>
</TD>
<td></td>
<TD>表中文名 :</TD>
<TD>
<select id="bzwm" name="bzwm">
<option value="">
请选择
</option>
</select>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TABLE>
<script type="text/javascript">
$("#ywflDm").change(function() {
var ywflDm=$("#ywflDm").val();
$.ajax({
"url": "${ctx}/bzdmb/bmlist/"+ywflDm,"type":"post",'success': function(content){
var dmbInfo=eval(content);
$("#bzwm").html("");
$("#bzwm").append("<option value='' >请选择</option>")
for(var i=0;i<dmbInfo.length;i++){
// var bm=dmbInfo[i]["bm"];
var bzwm=dmbInfo[i]["bzwm"];
var dmbDm=dmbInfo[i]["dmbDm"];
$("#bzwm").append("<option value='"+dmbDm+"'>"+bzwm+"</option>")
}
}});
})
</script>
原文链接:https://www.f2er.com/ajax/166239.html