日期:2014-05-16 浏览次数:20452 次
<tr>
<td align="right">学院:</td>
<td><select name="role" onBlur="checkRole(this)" onchange="populateMajor(this.options[this.selectedIndex].value)">
<option value="0">-请选择学院-</option>
<%
List<Department> list = new ArrayList<Department>();
DepartmentDao dao = new DepartmentDaoImpl();
list = dao.findAllDepartments();// 调用实现类的查询全部方法
for (int i = 0; i < list.size(); i++) {
Department d = list.get(i);
%>
<option value="<%=d.getD_id()%>"><%=d.getD_name()%></option>
<%
}
%>
</select>
<!--级联二级菜单 -->
<%
List<MajorAndClass> list1 = new ArrayList<MajorAndClass>();
MajorAndClassDao mdao = new MajorAndClassDaoImpl();
list1 = mdao.findAllMajorAndClass();// 调用实现类的查询全部方法
%>
<script type="text/javascript">
var onecount=0;//定义一个变量,记录Major个数
var listMajor= new Array();//定义一个数组,记录Major内容
<%
int count = 0;//listMajor下标
for (int i = 0; i < list1.size(); i++) {
MajorAndClass m = list1.get(i);
%>
listMajor[<%=count%>]= new Array(<%=m.getName()%>,<%=m.getM_id()%>,<%=m.getDepartment().getD_id()%>);//把list数据放入listMajor数组
<%count++;
}%>
onecount=<%=count%>;
function populateMajor(dID){//显示二级菜单Major
document.getElementById("major").options.length=0;
if(dID!=""){
var dID=parseInt(dID);
for(var i=0;i<onecount;i++)
{
if(listMajor[i][2]==dID)
{
document.getElementById("major").options[i]=new Option[listMajor[i][0],listMajor[i][1]];
}
}
}
}
</script>
</td>
<td>
<select id="major" name="major">
<option value="0" selected>-请选择专业-</option>
</select>
</td>