san.jsp
<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/interface/menu.js"></script>
</head>
<body>
<script type="text/javascript">
//根据国家id查询所属省或州
function queryjiedao()
{ //alert("开始拉");
var quId = $("qu").value;
//默认为不选择
if(quId == 0)
{
${"jiedao"}.options.length=0;
${"shequ"}.options.length=0;
}
else
{//alert("执行");
menu.getSelectAreasJieDao(quId,jiedaoCallback);
}
}
//根据国家id查询所属省或州的回调函数
function jiedaoCallback(jiedaos)
{
${"jiedao"}.options.length=0;
//每次获得新的数据的时候先把每二个下拉框架的长度清0
for(var i=0;i< jiedaos.length;i ++){
var value = jiedaos[i].bh;
var text = jiedaos[i].mc;
var option = new Option(text, value);
//根据每组value和text标记的值创建一个option对象
try{
$("jiedao").add(option);//将option对象添加到第二个下拉框中
}catch(e){
}
}
//同时关联第三级
var jiedaoId = ${"jiedao"}.value;
menu.getSelectAreasSheQu(jiedaoId,shequCallback);
}
//查询所属城市
function queryshequ()
{
var jiedaoId = $("jiedao").value;
menu.getSelectAreasSheQu(jiedaoId,shequCallback);
}
//查询所属城市回调函数
function shequCallback(shequs)
{
//每次获得新的数据的时候先把每三个下拉框架的长度清0
${"shequ"}.options.length=0;
for(var i=0;i< shequs.length;i ++){
var value = shequs[i].bh;
var text = shequs[i].mc;
var option = new Option(text, value);
//根据每组value和text标记的值创建一个option对象
try{
$("shequ").add(option);//将option对象添加到第三个下拉框中
}catch(e){
}
}
}
function change1()
{
queryjiedao();
}
function change2()
{
queryshequ();
}
</script>
<div align="center">
<h3>
<br>
</h3>
<!-- 我都奇怪了,我的<c>标签在这里不能用 -->
<select id="qu" οnchange="change1();">
<option selected="selected" value="0">
请选择
</option>
<%
for (int i = 0; i < items1.size(); i++)
{
Area area=new Area();
area=(Area)items1.get(i);
%>
<option value="<%=area.getBh()%>"><%=area.getMc()%></option>
<%
}
%>
</select>
<select id="jiedao" οnchange="change2();">
</select>
<select id="shequ">
</select>
</div>
对应的DAO文件不写了省了
dwr.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "http://getahead.org/dwr//dwr30.dtd">
<dwr>
<allow>
<create creator="new" javascript="menu">
<param name="class" value="service.impl.AreaManagerImpl" />
</create>
<!-- 要转换的Bean -->
<convert converter="bean" match="model.Area" />
</allow>
</dwr>