javascripterror 为空或不是对象.
16lz
2021-01-22
提示:document.myform.BigClassName.options为空或不是对象
贴出相关代码,具体错误行见红字部分
在线,解决即给分
subShowSearch(ShowType)
dimcount
ifShowType<>1andShowType<>2then
ShowType=1
endif
setrs=server.createobject("adodb.recordset")
sql="select*fromSmallClassorderbySmallClassIDasc"
rs.opensql,conn,1,1
%>
<scriptlanguage="JavaScript">
varonecount;
subcat=newArray();
<%
count=0
dowhilenotrs.eof
%>
subcat[<%=count%>]=newArray("<%=trim(rs("SmallClassName"))%>","<%=trim(rs("BigClassName"))%>","<%=trim(rs("SmallClassName"))%>");
<%
count=count+1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
functionchangelocation(locationid)
{
document.myform.SmallClassName.length=1;
varlocationid=locationid;
vari;
for(i=0;i<onecount;i++)
{
if(subcat[i][1]==locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length]=newOption(subcat[i][0],subcat[i][2]);
}
}
}
</script>
<tableborder="0"cellpadding="2"cellspacing="0"align="center">
<formmethod="Get"name="myform"action="search.asp"target="_blank">
<tr>
<tdheight="28"><selectname="Field"size="1">
<optionvalue="Title"selected>产品名称</option>
<optionvalue="Content">产品说明</option>
</select>
<%ifShowType=1then%>
</td>
</tr>
<tr>
<tdheight="28">
<%endif%>
<selectname="BigClassName"onChange="changelocation( document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)"size="1">
<optionselectedvalue="">所有大类</option>
<%
ifnot(rsBigClass.bofandrsBigClass.eof)then
rsBigClass.movefirst
dowhilenotrsBigClass.eof
response.Write"<optionvalue='"&trim(rsBigClass("BigClassName"))&"'>"&trim(rsBigClass("BigClassName"))&"</option>"
rsBigClass.movenext
loop
endif
%>
</select>
<%ifShowType=1then%>
</td>
</tr>
<tr>
<tdheight="28">
<%endif%>
<selectname="SmallClassName">
<optionselectedvalue="">所有小类</option>
</select>
<%ifShowType=1then%>
</td>
</tr>
<tr>
<tdheight="28">
<%endif%>
<inputtype="text"name="keyword"size=12value="关键字"maxlength="50"onFocus="this.select();">
<inputtype="submit"name="Submit"value="搜索"></td>
</tr>
</form>
</table>
<%
endsub
onChange="changelocation(this.value)"即可!
贴出相关代码,具体错误行见红字部分
在线,解决即给分
subShowSearch(ShowType)
dimcount
ifShowType<>1andShowType<>2then
ShowType=1
endif
setrs=server.createobject("adodb.recordset")
sql="select*fromSmallClassorderbySmallClassIDasc"
rs.opensql,conn,1,1
%>
<scriptlanguage="JavaScript">
varonecount;
subcat=newArray();
<%
count=0
dowhilenotrs.eof
%>
subcat[<%=count%>]=newArray("<%=trim(rs("SmallClassName"))%>","<%=trim(rs("BigClassName"))%>","<%=trim(rs("SmallClassName"))%>");
<%
count=count+1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
functionchangelocation(locationid)
{
document.myform.SmallClassName.length=1;
varlocationid=locationid;
vari;
for(i=0;i<onecount;i++)
{
if(subcat[i][1]==locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length]=newOption(subcat[i][0],subcat[i][2]);
}
}
}
</script>
<tableborder="0"cellpadding="2"cellspacing="0"align="center">
<formmethod="Get"name="myform"action="search.asp"target="_blank">
<tr>
<tdheight="28"><selectname="Field"size="1">
<optionvalue="Title"selected>产品名称</option>
<optionvalue="Content">产品说明</option>
</select>
<%ifShowType=1then%>
</td>
</tr>
<tr>
<tdheight="28">
<%endif%>
<selectname="BigClassName"onChange="changelocation( document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)"size="1">
<optionselectedvalue="">所有大类</option>
<%
ifnot(rsBigClass.bofandrsBigClass.eof)then
rsBigClass.movefirst
dowhilenotrsBigClass.eof
response.Write"<optionvalue='"&trim(rsBigClass("BigClassName"))&"'>"&trim(rsBigClass("BigClassName"))&"</option>"
rsBigClass.movenext
loop
endif
%>
</select>
<%ifShowType=1then%>
</td>
</tr>
<tr>
<tdheight="28">
<%endif%>
<selectname="SmallClassName">
<optionselectedvalue="">所有小类</option>
</select>
<%ifShowType=1then%>
</td>
</tr>
<tr>
<tdheight="28">
<%endif%>
<inputtype="text"name="keyword"size=12value="关键字"maxlength="50"onFocus="this.select();">
<inputtype="submit"name="Submit"value="搜索"></td>
</tr>
</form>
</table>
<%
endsub
13 个解决方案
#1
onChange="changelocation(this.value)"即可!
更多相关文章
- 字体图标的引入和通过媒体查询改变导航样式
- HTML样式和常用选择器
- 字体图标的引用和自定义样式/媒体查询的使用
- 数据库的CURD操作、PDO本质与原理的学习
- CSS之伪类选择器和简单盒子简单案例
- 伪类选择器与盒模型常用属性
- 伪类选择器-结构伪类、根据位置选择匹配
- 7.4——常用标签与应用场景之表格与单元格
- css伪类选择器和盒模型