<% for i = 1 to 10 %>
<input type="checkbox" name="chk_<%= i %>"> <%= i %>
<br>
<% next %>
<input type="submit" value="提交">
</form>
</BODY>
</HTML>
ptest.asp
--------------------------
<%
for each item in request.form
' 如果找到一个 checkbox
if instr(item, "chk_") > 0 then
'检测是否被选中
if lcase(request.form(item)) = "on" then
'求出这条记录的 id
id = replace(item, "chk_", "")
'--------- debug ----------
response.write "<br>" & id
'--------- debug ----------
'构造相应的插入语句
'sql = "insert into tbl where id=" & id
'插入数据库
'conn.execute(sql)
end if
end if
next
%>
for each item in request.form
' 如果找到一个 checkbox
if instr(item, "chk_") > 0 then
'检测是否被选中
if lcase(request.form(item)) = "on" then
'求出这条记录的 id
id = replace(item, "chk_", "")
'构造相应的插入语句
sql = "insert into tbl where id=" & id
'插入数据库
conn.execute(sql)
end if
end if
next