asp 复选框取值

来源:百度知道 编辑:UC知道 时间:2024/06/07 18:24:27
打勾1 嵌入式 打勾2 电源设计及应用 3 IC设计
4 移动终端 5 汽车电子 6 测试测量

我把 1 嵌入式 2 电源设计及应用写入数据r_checkbox里的字段c_box里,c_box字段的值是1,2
然后我做查询
<!--问题区域-->
<%dim test
test=Split(rst3("c_box"),", ")

for i=0 to ubound(test) %>
<input type="checkbox" name="MyCheckBox" value="1" <% if test(i)=1 then response.write ("checked") end if %>/>嵌入式
<input type="checkbox" name="MyCheckBox" value="2" <% if test(i)=2 then response.write ("checked") end if %>/>电源设计及应用
<input type="checkbox" name="MyCheckBox" value="3" <% if test(i)=3 then response.write ("checked") end if %>/>IC设计
<input type="checkbox" name="MyCheckBox" value="4" <% if test(i)=4 then response.write ("checked") end if %>/>移动终端
<input ty

<%dim test
test=Split(rst3("c_box"),", ")
dim title
title=split("嵌入式,电源设计及应用,IC设计,移动终端,汽车电子,测试测量",",")
for i=0 to ubound(title)

for each j in test

if j=i+1 then
checked=1
exit for
else
checked=0
end if

next
%>
<input type="checkbox" name="MyCheckBox" value="<%=(i+1)%>" <% if checked=1 then response.write ("checked='checked'") end if %>/><%=title(i)%>
<%
next
%>
这样就行了,不过选项很多时,效率就不行了……

test=Split(rst3("c_box"),", ")
改成 test=Split(replace(rst3("c_box")," ",""),", ")