注册 登录
编程论坛 ASP技术论坛

从数据库获取下拉列表的信息

zoujh0101 发布于 2010-11-17 15:36, 809 次点击
<%
Private Function setselected(op)
Dim i
i=1
if op=2 then
do while i<11 %>
<option value="<%=i%>"<%if bookedition=i then%>selected<%end if%>><%=i%>
</option>"
<%i=i+1
loop
end if
if op=1 then
'获取图书类型
Dim Rs,Sql
Set Rs=Server.Createobject("adodb.recordset")
sql=""select booktypename from booktypeinfo"
rs.open sql,actionconn,3,2
do while not rs.eof %>
<option value="<%=rs("booktypename")%>"<%if booktype=rs("booktypename")then %>selected<%end if%>><%=rs("booktypename")%></option>
<%rs.movenext
loop
rs.close
set rs=nothing
end if
end function
%>
有那位高手能帮我解释下这段代码的含义吗?其中红色部门能详细说明下吗?或者可以推荐我看那些相关内容的文章,或者有什么好的网址可推荐?多谢谢啦
5 回复
#2
hams2010-11-17 16:25
找本书或找个教程看
#3
gupiao1752010-11-17 16:55
刚介入编程的人,除非极具天赋,否则别指望看几遍就能马上理解其全部涵义,刻意去学或记东西真的没有这个必要!短时间练不出天才的!

还是那句老话,读码百遍,其意自现!很多东西用久了,自然你就记在心中了!
#4
zoujh01012010-11-19 15:33
谢谢 指点
#5
yms1232010-11-19 15:46
<%
Private Function setselected(op)
  Dim i
  i=1
  if op=2 then
    do while i<11
       With Response
           .Write "<option value="&i&"
           if bookedition=i then
              .Write " selected "
           end if
           .Write ">"&i
           .Write "</option>"
           i=i+1
        End With   
     loop
  end if
  if op=1 then
     '获取图书类型
    Dim Rs,Sql
    Set Rs=Server.Createobject("adodb.recordset")
    sql=""select booktypename from booktypeinfo"
    rs.open sql,actionconn,3,2
   do while not rs.eof
      With Response
         .Write "<option value="&rs("booktypename")
         if booktype=rs("booktypename")then
            .Write " selected "
         end if
         .Write ">"&rs("booktypename")&"</option>"
      End With
      rs.movenext
   loop
   rs.close
   set rs=nothing
 end if
end function
%>
养成注意格式的习惯很重要
#6
awke0022010-11-22 22:40

 沉下心来做一两个项目应该可以知道是什么意思了吧!
1