document.myform.BigClassName.options' 为空或不是对象
测试的一个二级分类,上次也是用的这个程序都成功了。对照着看也看看出是哪出了问题把程序贴出来麻烦帮看一下,谢谢
网页错误详细信息
消息: 'document.myform.BigClassName.options' 为空或不是对象
行: 75
字符: 1
代码: 0
程序代码:
<form method="POST" name="myform"> <% set rs=server.createobject("adodb.recordset") sql = "select * from [SmallClass] " rs.open sql,conn,1,1 %> <script language = "JavaScript"> var onecount; subcat = new Array(); <% count = 0 do while not rs.eof %> subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>","<%= trim(rs("SmallClassName"))%>"); <% count = count + 1 rs.movenext loop rs.close %> onecount=<%=count%>; function changelocation1(locationid) { document.myform.SmallClassName.length = 1; var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]); //这是第75行 } } } </script> <table width="100%" height="32" border="0" cellpadding="0" cellspacing="1"> <tr> <td height="30" align="left"> <% set rs=server.createobject("adodb.recordset") sql = "select * from [BigClass]" rs.open sql,conn,1,1 if rs.eof and rs.bof then response.write "请先添加栏目。" else %> <select name="BigClassid" id="BigClassid" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassid.selectedindex2].value)" size="1" > <option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option> <% dim selclass selclass=rs("BigClassName") rs.movenext do while not rs.eof %> <option value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option> <% rs.movenext loop end if rs.close %> </select> <select name="SmallClassName" id="SmallClassName" size="1"> <option value="">不指定小类</option> <% set rs=server.createobject("adodb.recordset") sql="select * from [SmallClass] where BigClassName='" & selclass & "'" rs.open sql,conn,1,1 if not(rs.eof and rs.bof) then %> <option value="<%=rs("SmallClassName")%>" selected="selected"><%=rs("SmallClassName")%></option> <% do while not rs.eof%> <option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option> <% rs.movenext loop end if rs.close %> </select> <input name="cubname" type="text" id="cubname" size="15" /> <input type="submit" name="Submit" value="提交" /> </td> </tr> </table> </form>