有关复选框默认选中的问题?

liguokun 2004-08-01 11:58:18
我用如下for语句生成了一系列的复选框,如何使得values为2、4、6、8的复选框默认选中?

<%
for i=0 to 10
%>
<input type="checkbox" name="Kind_checkbox" value=<%=i%> > 复选框<%=i%>
<p>
<%
next
%>
...全文
180 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liguokun 2004-08-02
  • 打赏
  • 举报
回复
这种问题挺多痛的!!
liguokun 2004-08-02
  • 打赏
  • 举报
回复
如果是下面的语句,那么复选框全部默认选中:
<%
for i=0 to 10
%>
<input type="checkbox" name="Kind_checkbox" value=<%=i%> checked > 复选框<%=i%>
<p>
<%
next
%>

之后加了一个IF语句,就什么反应都没有,一个也没有选中:
<%
for i=0 to 10
%>
<input type="checkbox" name="Kind_checkbox" value=<%=i%> <%if i=2 then%>checked<%end if%> > 复选框<%=i%>
<p>
<%
next
%>
liguokun 2004-08-02
  • 打赏
  • 举报
回复
试过了,上面两种方法都不行!!!
pizixt 2004-08-01
  • 打赏
  • 举报
回复
<input type="checkbox" name="Kind_checkbox" value="<%=i%>" <%if i mod 2=0 and i<>0 and i<>10 then response.write "checked"%>> 复选框<%=i%>
yslcuk 2004-08-01
  • 打赏
  • 举报
回复
加个判断就可以了
<%if (i=2 or i=4 or i=6 or i=8 ) then%>checked<%end if%>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧