各位兄弟指教一下我得问题
ywsws 2001-06-23 05:28:00 <!-- Sample JSP file -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Page Designer V3.5.2 for Windows">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>
</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="faq1.faq" />
<%
ResultSet RS = workM.executeQuery("SELECT distinct grade FROM fibercable");
String tt,tt1;
%>
<FORM name="form1">
<%
out.print("光缆等级 ");
%>
<SELECT size="1"name="grade" onChange="changelocation(document.form1.grade.options[document.form1.grade.selectedIndex].value)">
<%
String[] gx=new String[50];
int k=0;
while (RS.next()){
tt=RS.getString("grade");
gx[k]=tt;
k++;
%>
<OPTION value=<%=tt%>><%=tt%></OPTION>
<%
}
RS.close();
%>
</SELECT>
<%
String[][] nx=new String[100][2];
int n=0;
for(int i=0;i<k;i++)
{ResultSet RS1;
RS1=workM.nameQuery(gx[i]);
while(RS1.next()){
tt1=RS1.getString(1);
nx[n][0]=tt1;
nx[n][1]=gx[i];
n++;
}
RS1.close();
}
%>
<%
out.print(" ");
%>
<SELECT size="1" name="name">
</SELECT>
</FORM>
<script LANGUAGE=javascript>
nn=30; //这里的nn大小本应为数组nx的大小,即上面的n,但不知怎么引用
function changelocation(locationid)
{
document.form1.name.length = 0;
var locationid=locationid;
var i;
document.form1.name.options[0]=new Option('all','');
for(i=0;i<nn;i++)
{
if(nx[i][1]==locationid) //可以这样直接引用数组的值吗,运行老是报错nx未定义
{
document.form1.name.options[document.form1.name.length] = new Option(nx[i][1]);
}
}
}
</script>
</BODY>
</HTML>