81,122
社区成员




<!-- jsp -->
<html>
<head>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<%
Map<String,String> mapOne = new HashMap<String,String>();
mapOne.put("信息工程学院","信息工程学院");
mapOne.put("经济管理学院","经济管理学院");
mapOne.put("法学院","法学院");
%>
<!-- 二级联动菜单 -->
<script type="text/javascript">
/*声明两个数组,以便区别,具体操作,应该是通过底层返回一个list*/
var one = new Array("软件工程","信息工程","信息安全");
var two = new Array("国际贸易","财务管理","会计");
var three = new Array("法学","国际汉语");
/*该函数,控制二级级联操作*/
function specieSelChange(selBox)
{
var str;
if(selBox.value == "信息工程学院")
{
for(var i = 0; i < one.length; i ++)
{
str += "<option>" + one[i] + "</option>";
}
}
else if(selBox.value == "经济管理学院")
{
for(var i = 0; i < two.length; i ++)
{
str += "<option>" + two[i] + "</option>";
}
}
else
{
for(var i = 0; i < three.length; i ++)
{
str += "<option>" + three[i] + "</option>";
}
}
document.all('list').innerHTML = str;
}
</script>
<script type="text/javascript">
var req;
function validate() {
var str = document.getElementById("list").value;
alert(str);
//访问validate.do这个servlet,同时把获取的表单内容idField加入url字符串,以便传递给validate.do
var url = "<%=basePath%>/ClassScoreServlet";
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = function callback(){
if(req.readyState == 4 && req.status == 200) {
document.getElementById('info').innerHTML= req.responseText;
}
}
req.open("POST", url, true);
xmlHttpxmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.send(str);
}
</script>
<style type="text/css"> td {text-align:center}</style>
</head>
<body bgcolor="#434343">
<font color="#ffffff" size=+2>
<center> 班级成绩查询 </center>
<hr width="90%">
</font>
<center>
<table border="0" align="center" >
<tr>
<td> <font color="#FFFFFF">学院:</font></td>
<td>
<!-- 页面使用循环取出数据 如果需要更标准,请使用jstl标签,或者struts标签 -->
<select id="selBox" onchange="specieSelChange(this)" name="select1" style="width:120">
<option>---请选择---</option>
<option value="信息工程学院">信息工程学院 </option>
<option value="法学院">法学院 </option>
<option value="信息工程学院">信息工程学院 </option>
</select>
</td>
<td width="50"></td>
<!-- 第二个下拉框,开始执行二级联动 -->
<td>
<font color="#FFFFFF"> 专业:</font>
</td>
<td >
<!-- 该下拉框,使用自动生成 -->
<select id="list" name="select2" style="width:80" >
<option>--请选择--</option>
</select>
</td>
<td width="30"></td>
<td>
<button onclick="validate()"> 查看</button>
</td></tr>
</table>
</center>
<span id="info"></span>
</table>
</body>
</html>
<!--servlet-->
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();;
String str = request.getParameter("str");
out.print(str);
}