怎么实现asp下拉菜单读取数据库记录显示
1个回答
展开全部
<script language = "javascript">
var j;
j=0;
info = new Array();
<%set rs=conn.execute("select * from smallinfo order by ID desc")
if rs.eof then%>
info[0] = new Array("无小类","","");
<%else
i=0
do while not rs.eof
%>
info[<%=i%>] = new Array("<%=rs("smallname")%>","<%=rs("bigid")%>","<%=rs("id")%>");
<%rs.movenext
i=i+1
loop
end if
rs.close
%>
j=<%=i%>;
function changelocation1(locationid){
document.form1.scid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < j; i++){
if (info[i][1] == locationid){
document.form1.scid.options[document.form1.scid.length] = new Option(info[i][0], info[i][2]);
}
}
}
</script>
<form action='addnews_ok.asp' method=POST name="form1" onSubmit="return doCheck();">
<tr bgcolor="#FFFFFF">
<td align="right"><strong>新闻类别</strong></td>
<td ><select name="bcid" size="1" class="input1" onChange="changelocation1(document.form1.bcid.options[document.form1.bcid.selectedIndex].value)">
<%set rs=conn.execute("select * from biginfo order by ID desc")
if rs.recordcount=0 then%>
<option selected value="">无类别</option>
<%else%>
<option selected value="">请选择大类</option>
<%do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("bigname")%></option>
<%rs.movenext
loop
end if%>
</select>
<!--//////////////////////////City_select下拉列表//////////////////////////-->
<select name="scid" class="input1">
<option selected value="">请指定小类</option>
</select>
<font color=#ff0000>*</font></td>
</tr>
<input type=Submit value='发 表' name=Submit>
</form>
var j;
j=0;
info = new Array();
<%set rs=conn.execute("select * from smallinfo order by ID desc")
if rs.eof then%>
info[0] = new Array("无小类","","");
<%else
i=0
do while not rs.eof
%>
info[<%=i%>] = new Array("<%=rs("smallname")%>","<%=rs("bigid")%>","<%=rs("id")%>");
<%rs.movenext
i=i+1
loop
end if
rs.close
%>
j=<%=i%>;
function changelocation1(locationid){
document.form1.scid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < j; i++){
if (info[i][1] == locationid){
document.form1.scid.options[document.form1.scid.length] = new Option(info[i][0], info[i][2]);
}
}
}
</script>
<form action='addnews_ok.asp' method=POST name="form1" onSubmit="return doCheck();">
<tr bgcolor="#FFFFFF">
<td align="right"><strong>新闻类别</strong></td>
<td ><select name="bcid" size="1" class="input1" onChange="changelocation1(document.form1.bcid.options[document.form1.bcid.selectedIndex].value)">
<%set rs=conn.execute("select * from biginfo order by ID desc")
if rs.recordcount=0 then%>
<option selected value="">无类别</option>
<%else%>
<option selected value="">请选择大类</option>
<%do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("bigname")%></option>
<%rs.movenext
loop
end if%>
</select>
<!--//////////////////////////City_select下拉列表//////////////////////////-->
<select name="scid" class="input1">
<option selected value="">请指定小类</option>
</select>
<font color=#ff0000>*</font></td>
</tr>
<input type=Submit value='发 表' name=Submit>
</form>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询