请大家帮我看看这个程序!!
这是一个JSP页面,它包括两个下拉列表的动态关联
<%@ page contentType = "text/html;charset = SJIS" %>//编码方式为日语
<%@ page import = "java.sql.*" %>
<%
Connection con = null;
Statement stmt = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
String SID = null;
try{ //连接数据库
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Kigyo_jyoho_kanri","","");
stmt = con.createStatement();
rs1 = stmt.executeQuery("SELECT * FROM Mst_China_Sho"); //
rs2 = stmt.executeQuery("SELECT * FROM Mst_China_Toshi");
}
catch(SQLException e) {}
%>
<html>
<body>
<form name = "form1" method = "post" action = "process.jsp">
<select name = "ShoName" onchange = "showToshi()">
<option value = "0" selected>请选择</option>
<%
while (rs1.next()) {
SID = rs1.getString("Sho_Code");
%>
<option value = "<%= rs1.getString("Sho_Code")%>"><%= rs1.getString("Sho_Name")%></option>
<%
}
rs1.close();
%>
</select>
<SCRIPT LANGUAGE="JavaScript">
Toshi_Name = new Array();
Toshi_Code = new Array();
<%
int count = 0;
while (rs2.next()) {
String toshi_id = rs2.getString("Toshi_Code");
String toshi_name = rs2.getString("Toshi_Name");
out.println("Toshi_Name["+count+"] = "+ toshi_name );
out.println("Toshi_Code["+count+"] = "+ toshi_id );
count++;
}
rs2.close();
%>
function showToshi(){
selected = document.form1.ShoName.selectedIndex;
if (selected == 0) {
document.form1.ToshiName.length = 0;
document.form1.ToshiName.length++;
document.form1.ToshiName.options[document.form1.ToshiName.length-1].value="0";
document.form1.ToshiName.options[document.form1.ToshiName.length-1].text="お選んでください";
return ;
}
index = document.form1.ShoName.options[selected].value;
document.form1.ToshiName.length = 0;
for(i=0;i<Toshi_Name.length;i++){
if (Toshi_Code[i].indexOf(index) != -1) {
document.form1.ToshiName.length++;
document.form1ToshiName.options[document.form1.ToshiName.length-1].value = Toshi_Code[i];
document.form1ToshiName.options[document.form1.ToshiName.length-1].text =Toshi_Name[i];
}
}
}
</SCRIPT>
<SELECT NAME="ToshiName">
<option value="0" selected>请选择</option>
</SELECT>
</form>
</body>
</html>
编译时发生错误!!!