cf马哲一年能赚多少钱:ASP 下拉选择框如何实现可输入

来源:百度文库 编辑:中科新闻网 时间:2024/04/27 17:15:15
以下代码为动态下拉框,从数据库中读取下拉选择项,如果下拉框中没有的选择项,我要通过输入的形式输入,我要怎样实现??关链是不管是选择的还是输入的,都要将取赋值到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 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
%>