| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2202 人关注过本帖
标题:[原创]列表框中如何自动选择指定行?
只看楼主 加入收藏
qimed
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-5-31
收藏
得分:0 
我想表单提交后保留原选择的行。是仿着PLMM朋友的方法做的,可不知道哪里出做了,没达到原目的。请各位指教。
<%dim typeh typeh=request("type")%> <form name="type"> <select name="type"> <%dim indexNum indexNum=1 do while not indexNum>5 if indexNum=typeh then %> <option value="<%=indexNum%>" selected><%=indexNum%></option> <%else%> <option value="<%=indexNum%>"><%=indexNum%></option> <%end if indexNum=indexNum+1 loop %> </select> <input type = submit value=注册> </form>

[此贴子已经被作者于2005-6-1 15:13:26编辑过]

2005-06-01 14:22
qimed
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-5-31
收藏
得分:0 
[求助]
以下是引用PLMM在2005-5-31 15:53:21的发言: ; 上面是我的一段代码,仅供参考
我想表单提交后保留原选择的行。是仿着PLMM朋友的方法做的,可不知道哪里出做了,没达到原目的。请各位指教。
<%dim typeh typeh=request("type")%> <form name="type"> <select name="type"> <%dim i i=1 do while not i>5 if i=typeh then %> <option value="<%=i%>" selected><%=i%></option> <%else%> <option value="<%=i%>"><%=i%></option> <%end if i=i+1 loop %> </select> <input type = submit value=注册> </form>
2005-06-01 15:00
qimed
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-5-31
收藏
得分:0 
把原来的
      if indexNum=typeh then
一句改成
     if indexNum=cint(typeh) then
后就可以了。
2005-06-01 15:24
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
<%dim typeh typeh=request("type")%> <form name="type"> <select name="type"> <%dim i i=1 do while not i>5 response.write"<option value='"&i&"'"" if i=typeh then response.write "selected" response.write">"&i&"</option>" i=i+1 loop %> </select> <input type = submit value=注册> </form>

我很菜,但我很努力!
2005-06-02 07:57
qimed
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-5-31
收藏
得分:0 
您这办法更好哎.谢谢
2005-06-02 13:53
myliumin
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-7-30
收藏
得分:0 
再问一个.

有一个artlce表里面有typeid title content字段
  我要输出
  typeid=1时所有的文章,然后,再输出typeid=2时所有的文章.一直到typeid的末尾...这样写行不行??
  简单的说,这个功能就是按分类输出文章标题,我想做一个文章目录.
  
  dim typeid
  for typeid=1 to 4
  
  &lt;%while not rs.eof%&gt;
  
  select *
  from artcle
  where a_typeid="&amp;typeid&amp;"
  order by ID desc
  
  &lt;%
  rs.movenext
  wend
  %&gt;

谢谢回复.

可是这样不行啊...这样显示的只是

分类名 文章名 的方式啊....我要输出的分类名没有输出来哦.HOHO.

我的是这样的效果(分类名,和分类的文章名,我都要它自动输出)
分类1(即a_typeid=1)的时候
分类1的文章1
分类1的文章2
...................
分类1的文章末
分类2
分类2的文章1
分类2的文章1
..................
分类4
..................

我看过DreamWeaver的教程,这种东西叫做嵌套重复区域!!!!!!!它生成的
代码是用了两个rs记录集,建了两个表,我现在不想要建两个表,我想一个表,实现这个功能.
2005-07-30 22:42
toolag
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2005-7-30
收藏
得分:0 
write 的 时候请注意 “selected”与已存在HTML之间的 空格, 不添加空格容易造成无效甚至错误 较好的写法是类似如下: Response.Write "<option value='"&i&"'" If i=typeh Then Response.Write " selected" Response.Write ">"&i&"</option>"

[此贴子已经被作者于2005-7-30 23:27:27编辑过]


VB, Delphi, ASP, PHP, JSP, .NET MS SQL, My SQL, Oracle Diablo, StarCraft, WarCraft, World of Warcraft
2005-07-30 23:25
toolag
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2005-7-30
收藏
得分:0 
以下是引用myliumin在2005-7-30 22:42:13的发言: 再问一个. 有一个artlce表里面有typeid title content字段   我要输出   typeid=1时所有的文章,然后,再输出typeid=2时所有的文章.一直到typeid的末尾...这样写行不行??   简单的说,这个功能就是按分类输出文章标题,我想做一个文章目录.      dim typeid   for typeid=1 to 4      <%while not rs.eof%>      select *   from artcle   where a_typeid="&typeid&"   order by ID desc      <%   rs.movenext   wend   %> 谢谢回复. 可是这样不行啊...这样显示的只是 分类名 文章名 的方式啊....我要输出的分类名没有输出来哦.HOHO. 我的是这样的效果(分类名,和分类的文章名,我都要它自动输出) 分类1(即a_typeid=1)的时候 分类1的文章1 分类1的文章2 ................... 分类1的文章末 分类2 分类2的文章1 分类2的文章1 .................. 分类4 .................. 我看过DreamWeaver的教程,这种东西叫做嵌套重复区域!!!!!!!它生成的 代码是用了两个rs记录集,建了两个表,我现在不想要建两个表,我想一个表,实现这个功能.
现在问题是 您的 分类名 根据什么来呢? 1,2,3,4 只是typeid, 不是分类名 typename, 只好 分类typeid 显示了
<% Dim typeid,sql For typeid=1 to 4 Response.Write "分类"&typeid&"<ul>" sql = SELECT * FROM article WHERE a_typeid="&typeid&" ORDER BY id DESC Set rs = conn.execute(sql) while Not rs.eof Response.Write "<li><a href=''view.asp?a >"&rs("title")&"</a></li>" rs.MoveNext Wend rs.Close Set rs = Nothing Response.Write "</ul><br>" Next conn.Close %>
感觉这个article表缺少 id, typeid不能表示唯一性, 如果要达到 分类名的 目的, 还是需要 额外的 表 或者至少 asp代码中对于 typeid的强制分类

[此贴子已经被作者于2005-7-30 23:41:43编辑过]


VB, Delphi, ASP, PHP, JSP, .NET MS SQL, My SQL, Oracle Diablo, StarCraft, WarCraft, World of Warcraft
2005-07-30 23:41
快速回复:[原创]列表框中如何自动选择指定行?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016343 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved