请教版主及各位大哥我在做一个表单时当选择了父栏目后希望能跳出子栏目.朋友告诉我要用到一段VB代码.我从别的网站上粘贴并修改了这样一段代码但是还是跳不出子栏目.网页错误提示是"document.frmAnnounce.classid为空或对象不存在"请各位帮小弟看看是怎么回事,小弟特急呀
<!--#include file="dbconn.inc"--> <% sql="select * from zxnclass order by nclassid asc" rs.open sql,conn,1,1
%> <html> <head> <title>无标题文档</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
这就是粘贴过来的VB代码<script language = "JavaScript"> var onecount; onecount=0; subcat = new Array(); <% count = 0 do while not rs.eof %> subcat[<%=count%>] = new Array("<%= trim(rs("Nclass"))%>","<%= trim(rs("classid"))%>","<%= trim(rs("Nclassid"))%>"); <% count = count + 1 rs.movenext loop rs.close %> onecount=<%=count%>;
function changelocation(locationid) { document.frmAnnounce.Nclassid.length = 0;
var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.frmAnnounce.Nclassid.options[document.frmAnnounce.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]); } } } </script>
</head>
<body bgcolor="#FFFFFF" text="#000000"> <form name="frmannounce" method="post" action="input_answer.asp"> <table width="75%" border="1" height="351" align="center"> <tr> <td width="11%" height="13">选择栏目</td> <td width="89%" height="13"> <% sql = "select * from zxclass" rs.open sql,conn,1,1 if rs.eof and rs.bof then response.write "请先添加栏目。" response.end else %> <select name="classid" onChange="changelocation(document.frmAnnounce.classid.options[document.frmAnnounce.classid.selectedIndex].value)" size="1"> <option selected value="">请选择栏目</option> <% do while not rs.eof %> <option value="<%=trim(rs("classid"))%>"><%=trim(rs("classname"))%></option> <% rs.movenext loop end if rs.close set rs = nothing conn.Close set conn = nothing %> </select> <select name="Nclassid" size="1"> </select> </td> </tr> <tr> <td width="11%" height="18">时间</td> <td width="89%" height="18"> <input type="text" name="textfield"> </td> </tr> <tr> <td width="11%" height="25">标题</td> <td width="89%" height="25"> <input type="text" name="textfield2"> </td> </tr> <tr> <td width="11%">内容</td> <td width="89%"> <textarea name="textfield3" cols="60" rows="13"></textarea> </td> </tr> </table> <p align="center"> <input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重写"> </p> </form> </body> </html>