View Full Version : Retrieve the value of multiple checkbox

02-17-2003, 04:03 PM
Hi! Here am I again with a (maybe stupid...) problem:

I have on a page 8 checkboxs. I'm doing something like this:
<form action = "2.asp">
<%for i =1 to 8%>
<TD><INPUT type="checkbox" id=checkbox1 name="pendente<%=i%>"></TD>

How can I, on the "2.asp" page, when I'm doing my SQL Insert string, retrieve the value of those checkbox's? I need to know If the first is "on" or not, the second, and so on...

I can't do this!!! I've been trying for 2 days!
Please help...


02-17-2003, 05:14 PM
With checkboxes, the value that you get by default will be "on" if the box is checked or it will be null if the box isn't checked.

for i =1 to 8
response.write "The value of checkbox "&i&" is: "&request.querystring("pendente"&i)&"<br>"

The output will be the following if you check boxes 1, 5, and 8:

The value of checkbox 1 is: on
The value of checkbox 2 is:
The value of checkbox 3 is:
The value of checkbox 4 is:
The value of checkbox 5 is: on
The value of checkbox 6 is:
The value of checkbox 7 is:
The value of checkbox 8 is: on

edit: You can use if-statements to change the null values to "off" since most people like strings better.

02-18-2003, 03:11 PM

Just to thank's the help. It was just what I nedeed!...


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum