1、结果显示页面index.jsp关键代码:
<%@ page contentType="text/html; charset=GBK" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="conn" scope="page"/>
<%
ResultSet rs_super=conn.executeQuery("select ID,superType from V_type group by ID,superType");
int superID=-1;
int P_superID=-1;
String superName="";
if(rs_super.next()){
superID=rs_super.getInt(1);
}
%>
<html>
<head>
<title>无刷新的级联下拉列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script language="javascript" src="js/AjaxRequest.js"></script>
</head> <script language="javascript">
function selSubType(val){
var loader=new net.AjaxRequest("selSubType.jsp?superID="+val+"&nocache="+new Date().getTime (),deal,onerror,"GET");
}
//回调函数
function deal(){
document.getElementById("subType").innerHTML=this.req.responseText;
}
function onerror(){
alert("出错了");
}
</script>
<script language="javascript">
function mycheck(){
form1.submit();
}
</script>
<body onLoad="selSubType(<%=superID%>)">
<form action="goods_add_deal.jsp" method="post" name="form1">
所属大类: <select name="select" id="select" onChange="selSubType(this.value)">
<%rs_super.first();
do{
superID=rs_super.getInt(1);
superName=rs_super.getString(2);
%>
<option value="<%=superID%>"><%=superName%></option>
<%}while(rs_super.next());%>
</select>
所属小类:<span id="subType">正在调用小分类信息……</span></br>
<input name="Button2" type="button" value="保存" onClick="mycheck()">
<input name="Submit22" type="reset" value="重置">
<input name="Submit3" type="button" value="返回" onClick="JScript:history.back(-1)">
</form>
</body>
</html>
I
<%@ page contentType="text/html; charset=GBK" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="conn" scope="page"/>
<%
ResultSet rs_super=conn.executeQuery("select ID,superType from V_type group by ID,superType");
int superID=-1;
int P_superID=-1;
String superName="";
if(rs_super.next()){
superID=rs_super.getInt(1);
}
%>
<html>
<head>
<title>无刷新的级联下拉列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script language="javascript" src="js/AjaxRequest.js"></script>
</head> <script language="javascript">
function selSubType(val){
var loader=new net.AjaxRequest("selSubType.jsp?superID="+val+"&nocache="+new Date().getTime (),deal,onerror,"GET");
}
//回调函数
function deal(){
document.getElementById("subType").innerHTML=this.req.responseText;
}
function onerror(){
alert("出错了");
}
</script>
<script language="javascript">
function mycheck(){
form1.submit();
}
</script>
<body onLoad="selSubType(<%=superID%>)">
<form action="goods_add_deal.jsp" method="post" name="form1">
所属大类: <select name="select" id="select" onChange="selSubType(this.value)">
<%rs_super.first();
do{
superID=rs_super.getInt(1);
superName=rs_super.getString(2);
%>
<option value="<%=superID%>"><%=superName%></option>
<%}while(rs_super.next());%>
</select>
所属小类:<span id="subType">正在调用小分类信息……</span></br>
<input name="Button2" type="button" value="保存" onClick="mycheck()">
<input name="Submit22" type="reset" value="重置">
<input name="Submit3" type="button" value="返回" onClick="JScript:history.back(-1)">
</form>
</body>
</html>
I