ASP为什么循环出来的值不在下拉菜单里

<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transiti... <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file = "../config/db.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>

<style type="text/css">
<!--
.style3 {font-size: 12px}
.style5 {font-family: "宋体"; font-size: 12px; }
-->
</style>
<script language=javascript>
function check()
{
if (form1.textfield.value==""){
alert ("请输入登录帐号");
form1.textfield.focus()
return false
}
if (form1.textfield2.value==""){
alert ("请登录密码");
form1.textfield2.focus()
return false
}
if (form1.select.value==""){
alert ("请选择所属部门");
form1.select.focus()
return false
}
if (form1.textfield3.value==""){
alert ("请填写姓名");
form1.textfield3.focus()
return false
}

}

</script>
</head>

<body>
<form name="form1" method="post" action="admintjlz.asp" onSubmit="return check()">

<table width="400" border="1" align="center" cellpadding="0" cellspacing="0" background="../imager/bj.gif">
<tr>
<td height="30" colspan="2"><div align="center"><strong>添加管理人员</strong></div></td>
</tr>
<tr>
<td width="87" height="30"><div align="center" class="style5">登录帐号:</div></td>
<td width="307"><input name="textfield" type="text" style="width:160px;height:18px "></td>
</tr>
<tr>
<td height="30"><div align="center" class="style5">登录密码:</div></td>
<td><input name="textfield2" type="password" style="width:160px;height:18px "></td>
</tr>
<tr>
<td height="30"><div align="center" class="style5">所属部门:</div></td>
<td><span class="style3" style="font-family: "宋体"">
<select name="select" style="width:160px;height:18px " >
<% dim rst,sql
set rst=Server.CreateObject("ADODB.recordset")
sql="select * from province "
rst.open sql,conn,1,1
do while not rst.eof
%>
<option ><%=rst("nc_name")%></option>
</select>
</span>
<%
rst.movenext
loop
'end if
rst.close
set rst=nothing
'end if
%>

</td>
</tr>
<tr>
<td height="30"><div align="center" class="style5">姓名:</div></td>
<td><input name="textfield3" type="text" style="width:160px;height:18px "></td>
</tr>
<tr>
<td height="30" colspan="2"><div align="center">
<input type="submit" name="Submit" value="提交">

</div>
</td>
</tr>

</table>
</form>

</body>
</html>
请各位高手指点
展开
 我来答
透彻还清心的繁花G
2010-04-27 · TA获得超过3774个赞
知道小有建树答主
回答量:1674
采纳率:33%
帮助的人:809万
展开全部
</select>
</span>
<%
rst.movenext
loop
'end if
rst.close
set rst=nothing
'end if
%>
改成
<%
rst.movenext
loop
'end if
rst.close
set rst=nothing
'end if
%>
</select>
</span>

因为你在循环未结束就已经有一个</select>关闭了下拉列表的标签,所以循环出来的记录会跑到下拉列表的外面去..
lanniaogzs
2010-04-27 · TA获得超过409个赞
知道小有建树答主
回答量:1190
采纳率:0%
帮助的人:1019万
展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file = "../config/db.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>

<style type="text/css">
<!--
.style3 {font-size: 12px}
.style5 {font-family: "宋体"; font-size: 12px; }
-->
</style>
<script language=javascript>
function check()
{
if (form1.textfield.value==""){
alert ("请输入登录帐号");
form1.textfield.focus()
return false
}
if (form1.textfield2.value==""){
alert ("请登录密码");
form1.textfield2.focus()
return false
}
if (form1.select.value==""){
alert ("请选择所属部门");
form1.select.focus()
return false
}
if (form1.textfield3.value==""){
alert ("请填写姓名");
form1.textfield3.focus()
return false
}

}

</script>
</head>

<body>
<form name="form1" method="post" action="admintjlz.asp" onSubmit="return check()">

<table width="400" border="1" align="center" cellpadding="0" cellspacing="0" background="../imager/bj.gif">
<tr>
<td height="30" colspan="2"><div align="center"><strong>添加管理人员</strong></div></td>
</tr>
<tr>
<td width="87" height="30"><div align="center" class="style5">登录帐号:</div></td>
<td width="307"><input name="textfield" type="text" style="width:160px;height:18px "></td>
</tr>
<tr>
<td height="30"><div align="center" class="style5">登录密码:</div></td>
<td><input name="textfield2" type="password" style="width:160px;height:18px "></td>
</tr>
<tr>
<td height="30"><div align="center" class="style5">所属部门:</div></td>
<td><span class="style3" style="font-family: "宋体"">
<select name="select" style="width:160px;height:18px " >
<% dim rst,sql
set rst=Server.CreateObject("ADODB.recordset")
sql="select * from province"
rst.open sql,conn,1,1
do while not rst.eof
%>
<option ><%=rst("nc_name")%></option>
</select>
</span>
</td>
</tr>
<tr>
<td height="30"><div align="center" class="style5">姓名:</div></td>
<td><input name="textfield3" type="text" style="width:160px;height:18px "></td>
</tr>
<tr>
<td height="30" colspan="2"><div align="center">
<input type="submit" name="Submit" value="提交">

</div>
</td>
</tr>

</table>
</form>

</body>
</html>

把你的代码这样修改一下就OK了,因为你是直接查询的字段,并没有安装最新的ID序号来查询,所以没有必要个循环语句。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式