jsp二级联动菜单

xixiclear 2006-01-21 12:22:48
连接mysql,我的第二级菜单显示是字段名,而不是内容,请高手指点。

<html>
<head>
<title>SIGN UP</title>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/reg?user=root&password=625&useUnicode=true&characterEncoding=ISO8859_1" ;
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
ResultSet rs;
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
int count = 0;
rs=stmt.executeQuery("select * from University");
while(rs.next())
{
String university=new String(rs.getString("University").getBytes("GBK"),"ISO8859_1");
%>
subcat[<%=count%>] = new Array("<%="university"%>","<%=rs.getInt("InCountry")%>","<%=rs.getInt("PI_Key")%>");//2úéúêy×é
<%
count = count + 1;
}
%>
onecount=<%=count%>;

function changelocation(id)
{
document.form1.uselect.length = 0;

var id=id;
var i;
document.form1.uselect.options[0] = new Option('--Select--','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == id)
{
document.form1.uselect.options[document.form1.uselect.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}

</script>
<script LANGUAGE=javascript>
changelocation(document.form1.ctselect.options [document.form1.ctselect.selectedIndex].value); //将一级分类的value传给changelocation()函数,生成二级分类的列表
</script>
</head>

<body>
<div align="center"></div>
<form name="form1" method="post" action="" >
<table width="609" border="1" align="center">
<tr>
<td width=21% height="2" bgcolor="#efefef"> <div align="center" class="style2">Surname</div></td>
<td width=79% height="2"><span class="style2"><b>
<b>
<input name="Surname" type="text" id="date" size="60">
</b> </b></span></td>
</tr>
<tr>
<td width=21% height="2" bgcolor="#efefef"> <div align="center" class="style2">GivenName</div></td>
<td width=79% height="2"><span class="style2"><b>
<b>
<input name="GivenName" type="text" id="date" size="60">
</b> </b></span></td>
</tr>
<tr>
<td width=21% height="2" align="center" bgcolor="#efefef">Country</td>
<td height="2"><span class="style5">
<select name="ctselect" id="ctselect" onChange="changelocation(document.form1.ctselect.options[document.form1.ctselect.selectedIndex].value)">
<option value="2">--Select--</option>

<%
rs=stmt.executeQuery("select * from Country");
while(rs.next())
{
String Country = new String(rs.getString("Country").getBytes("ISO8859_1"),"ISO8859_1");
System.out.println(Country);
%>
<option value="<%=rs.getInt("PI_Key")%>"><%=Country%></option>
<%
}
%>
</select></td>
</tr>
<tr>
<td width=21% height="2" align="center" bgcolor="#efefef">University</td>
<td>
<select name="uselect">
<option value="" selected>--Select--</option>
</select>
</td>
</tr>

<tr>
<td width=21% height="15" bgcolor="#efefef"> <div align="center" class="style8">City</div></td>
<td height="15">
<span class="style8">
<input name="City" type="text" id="date" size="60">
</font></b></span></td>
</tr>
<tr>
<td height="15" bgcolor="#efefef"> <div align="center">Organization</div></td>
<td height="15"> <input name="Organization" type="text" id="date" size="60">
</td>
</tr>
<tr>
<td height="15" bgcolor="#efefef"> <div align="center">Street</div></td>
<td >
<input name="Street" type="text" id="date" size="60">
</td>
</tr>
<tr>
<td width=21% height="15" bgcolor="#efefef"> <div align="center">Phone</div></td>
<td ><input name="Phone" type="text" id="date" size="60">
</td>
</tr>
<tr>
<td width=21% height="15" bgcolor="#efefef"> <div align="center">PostalCode</div></td>
<td height="15"><input name="PostalCode" type="text" id="date" size="60">
<div align="center"></div></td>
</tr>
<tr>
<td height="44" colspan="2">
<div align="center">
<input type="submit" name="Submit3" value="1">
      
<input type="reset" name="Submit22" value="2">
</div></td>
</tr>

</table>
</form>
</center>
</div>
</body>
</html>
...全文
222 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xixiclear 2006-01-21
  • 打赏
  • 举报
回复
在哪?没看到:(有没有人帮我看呀,我郁闷好久了!
gekie 2006-01-21
  • 打赏
  • 举报
回复
看看这里实现的菜单:http://www.hp198.com/

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧