ASP 下拉选择框如何实现可输入
以下代码为动态下拉框,从数据库中读取下拉选择项,如果下拉框中没有的选择项,我要通过输入的形式输入,我要怎样实现??关链是不管是选择的还是输入的,都要将取赋值到name="...
以下代码为动态下拉框,从数据库中读取下拉选择项,如果下拉框中没有的选择项,我要通过输入的形式输入,我要怎样实现??关链是不管是选择的还是输入的,都要将取赋值到name="szclass"的SZCLASS项
<select name="szclass" size="1" >
<option value="" selected>请选择收支项目</option>
<% do while not rs.eof %>
<option value="<%=trim(rs("ClassName"))%>"><%=trim(rs("ClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> 展开
<select name="szclass" size="1" >
<option value="" selected>请选择收支项目</option>
<% do while not rs.eof %>
<option value="<%=trim(rs("ClassName"))%>"><%=trim(rs("ClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> 展开
1个回答
展开全部
用数据库可以实现
<select name="szclass" size="1">
<%
option explicit
response.buffer=true
dim conn
dim connstr
dim db
db="classname.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
sql="select * from ANclass where classid=1
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("ClassName")%>">
<%=rs("ClassName")%>
</option>
<% rs.movenext
do while not rs.eof%>
<option selected value="<%=rs("ClassName")%>">
<%=rs("ClassName")%>
</option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
<select name="szclass" size="1">
<%
option explicit
response.buffer=true
dim conn
dim connstr
dim db
db="classname.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
sql="select * from ANclass where classid=1
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("ClassName")%>">
<%=rs("ClassName")%>
</option>
<% rs.movenext
do while not rs.eof%>
<option selected value="<%=rs("ClassName")%>">
<%=rs("ClassName")%>
</option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询