二级级联菜单

jsp:
 类别:




js:
$(document).ready(function(){ 
//改变下一级菜单
$("#type").change(function(){
	var $name = $("#name");
//移除name下拉菜单下的值
	$name.children().remove();
//访问action方法
$.get("<%=basePath%>expertInfo/expertInfo_doApplyName.action?t="+new Date(),"type=" + $(this).val(), function(data){
//往下拉菜单中添加值
	var $option = $("");
	$name.append($option); 
	$(data).find("name").each(function(i,n){
$option = $("");
	$name.append($option);}); 
			}); 
		}); 
		});  

action:
public void doApplyName(){
response.setContentType("text/xml;charset=utf-8");
PrintWriter out;
try {
	out = response.getWriter();
	//获取URL中的中文
	String major = new String(request.getParameter("major").getBytes("ISO-8859-1"),"gb2312");
	Map params = new HashMap();
	params.put("major", major);
	expertInfoList = expertInfoService.selectByParams(params);
	StringBuffer sub = new StringBuffer();
	sub.append("");
	for (ExpertInfo expertInfo : expertInfoList) {
		sub.append("");
		sub.append("" + expertInfo.getId() + "");
		sub.append("" + expertInfo.getRealname() + "");
		sub.append("");
	}
	sub.append("");
	out.println(sub.toString());
		} catch (IOException e) { 
			e.printStackTrace();
		}
	}


 

你可能感兴趣的:(二级级联菜单)