连接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>
<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>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货