这段代码错在哪里啊?
放在一个单独的文件里测试没有任何问题,为什么一旦放在一个完整的页面里却出错,小类里的项目都跑到大类里了!而且下面的代码也出错了。。。 郁闷啊~ 大家帮我看看是怎么回事?
<select name="s1" onChange="redirec(document.form2.s1.options.selectedIndex)">
<option value="请选择" selected>岗位类别大类</option>
<%
set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from classification order by position_id desc"
rs.open sql,conn,1,1
while not rs.eof%>
<option value="<%=rs("position_id")%>"><%=rs("position_name")%></option>
<%rs.movenext
wend
rs.close
set rs=nothing
%>
</select>
<select name="s2">
<option value="请选择" selected>岗位类别小类</option>
</select>
<script language="javascript">
//获取一级菜单长度
var select1_len = document.form2.s1.options.length;
var select2 = new Array(select1_len);
//把一级菜单都设为数组
for (i=0; i<select1_len; i++)
{ select2[i] = new Array();}
//定义基本选项
select2[0][0] = new Option("请选择", " ");
select2[1][0] = new Option("轮机长", " ");
select2[1][1] = new Option("大管", " ");
select2[1][2] = new Option("二管", " ");
select2[1][3] = new Option("三管", " ");
select2[1][4] = new Option("加油", " ");
select2[1][5] = new Option("机头", " ");
select2[1][6] = new Option("机工", " ");
select2[1][7] = new Option("轮机实习生", " ");
select2[1][8] = new Option("铜匠", " ");
select2[1][9] = new Option("电机员", " ");
select2[2][0] = new Option("甲板实习生", " ");
select2[2][1] = new Option("水头", " ");
select2[2][2] = new Option("一水", " ");
select2[2][3] = new Option("二水", " ");
select2[2][4] = new Option("船长", " ");
select2[2][5] = new Option("大副", " ");
select2[2][6] = new Option("二副", " ");
select2[2][7] = new Option("三副", " ");
select2[2][8] = new Option("木匠", " ");
select2[2][9] = new Option("报务员", " ");
select2[3][0] = new Option("大厨", " ");
select2[3][1] = new Option("管事", " ");
select2[3][2] = new Option("二厨", " ");
select2[3][3] = new Option("服务生", " ");
//联动函数
function redirec(x)
{
var temp = document.form2.s2;
for (i=0;i<select2[x].length;i++)
{ temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);}
temp.options[0].selected=true;
}
</script>
-----------------------------------------------------------------
<select name="s11" onChange="redirec1(document.form2.s11.options.selectedIndex)">
<option value="请选择" selected>航线区域大类</option>
<%
set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from sail order by fid desc"
rs.open sql,conn,1,1
while not rs.eof%>
<option value="<%=rs("fid")%>"><%=rs("sail")%></option>
<%rs.movenext
wend
rs.close
set rs=nothing
%>
</select>
<select name="s21">
<option value="请选择" selected>航线区域小类</option>
</select>
<script language="javascript">
//获取一级菜单长度
var select1_len1 = document.form2.s11.options.length;
var select21 = new Array(select1_len1);
//把一级菜单都设为数组
for (i=0; i<select1_len1; i++)
{ select21[i] = new Array();}
//定义基本选项
select21[0][0] = new Option("请选择", " ");
select21[1][0] = new Option("东南亚", " ");
select21[1][1] = new Option("北美", " ");
select21[1][2] = new Option("南美", " ");
select21[1][3] = new Option("欧洲", " ");
select21[1][4] = new Option("印度洋", " ");
select21[1][5] = new Option("其他远洋", " ");
select21[2][0] = new Option("南北航线", " ");
select21[2][1] = new Option("江海航线", " ");
select21[2][2] = new Option("其他航线", " ");
//联动函数
function redirec1(x)
{
var temp1 = document.form2.s21;
for (i=0;i<select21[x].length;i++)
{ temp1.options[i]=new Option(select21[x][i].text,select21[x][i].value);}
temp1.options[0].selected=true;
}
</script>
不好意思,水平有限~~~在此先谢过。