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

求checkbox 0 1 Split 例子(已解决)

letla 发布于 2009-09-23 09:35, 1139 次点击
小弟数据库里有一个字段,其中一条数据如下:0|0|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1
添加和修改数据的时候是想用checkbox来勾选,但是搞不清楚checkbox的值。
望哪位高人提供个例子给小弟啊。
谢谢大家了。

[ 本帖最后由 letla 于 2009-9-23 13:43 编辑 ]
5 回复
#2
aspic2009-09-23 10:14
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
 
<body>
<%
a = "1|0|1"
b = Split(a, "|")
'假设你知道第几个是干什么的 当然你应该知道
%>
<input type="checkbox" name="c1" <%If b(0) = "1" Then%> checked="checked"<%End If%> /><label for="c1">第一项</label>
<input type="checkbox" name="c2" <%If b(1) = "1" Then%> checked="checked"<%End If%> /><label for="c2">第二项</label>
<input type="checkbox" name="c3" <%If b(2) = "1" Then%> checked="checked"<%End If%> /><label for="c3">第三项</label>
</body>
</html>
#3
letla2009-09-23 10:32
感谢楼上老兄的支持,可能我还没表达清楚意思。
我是不知道checkbox在提交的数据是个什么值,
我是想要勾选的时候提交值为1,未勾选的时候提交的值为0
#4
aspic2009-09-23 10:58
你又说其中一条数据如下
那就拼接数据呗
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
 
<body>
<form action="?action=post" method="post">
    <input type="checkbox" value="1" name="c1" />
    <input type="checkbox" value="1" name="c2" />
    <input type="checkbox" value="1" name="c3" />
    <input type="checkbox" value="1" name="c4" />
    <input type="checkbox" value="1" name="c5" />
    <input type="submit" value="提交" />
</form>
<%
If Request("action") = "post" Then
    c1 = Request("c1")
    c2 = Request("c2")
    c3 = Request("c3")
    c4 = Request("c4")
    c5 = Request("c5")
    If c1 <> 1 Then c1 = 0
    If c2 <> 1 Then c2 = 0
    If c3 <> 1 Then c3 = 0
    If c4 <> 1 Then c4 = 0
    If c5 <> 1 Then c5 = 0
    Response.Write c1&"|"&c2&"|"&c3&"|"&c4&"|"&c5
End If     
%>
</body>
</html>
类似这样呢
#5
aspic2009-09-23 10:59
2#是显示方式
4#是添加方式
#6
letla2009-09-23 13:45
没看到结帖在哪里,麻烦版主帮忙搞下。
1