View Full Version : looping through checkboxes on a form

08-19-2004, 12:44 PM
I want to loop through some checkboxes & extract their name & value. actually i want an if statement that says if they are empty write nothing & if they arent then extract name & value of checkbox. i know how to do the if & extract the values etc but not the loop. at the moment i have really long code that looks at each checkbox tests if its empty & if it isnt then extracts the values I need.

can anyone help? this is what my code is starting to look like

Dim strSC, strCDRom, strGLS
strSC = Trim(Request.Form("shortform catalogue"))
strCDROM = Trim(Request.Form("catalogue on CD Rom"))
strGLS = Trim(Request.Form("Guard Locking systems"))
If strSC = "" Then
strMain = strMain
strMain = strMain & "Shortform catalogue: " & strSC &vbcrlf
End If
If strCDROM = "" Then
strMain = strMain
strMain = strMain & "catalogue on CD Rom " & strCDROM &vbcrlf
End If

& there are 19 of these checkboxes

08-19-2004, 01:57 PM
This loops through the checkboxes named check1, check2, check3, ...check19.

for i = 1 to 19
chk = request.form("check" & i)
if chk<>"" then
'checkbox is checked
response.write "check" & i & " is checked with the value of " & chk & "<br />"
end if