|
Hi
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
Else
strMain = strMain & "Shortform catalogue: " & strSC &vbcrlf
End If
If strCDROM = "" Then
strMain = strMain
Else
strMain = strMain & "catalogue on CD Rom " & strCDROM &vbcrlf
End If
& there are 19 of these checkboxes
thanks
|
|
|
One method is to name all your checkboxes with a common prefix so you can programmatically identify them later. For example:
<input type=checkbox name="CB_Catalog" value=1>
<input type=checkbox name="CB_GuardLock" value=1>
|
|
Then in your ASP, do something like this:
for each field in Request.Fom
if Left(field,3) = "CB_" and Request.Form(field) <> "" then
strMain = strMain & field & ": " & Request.Form(field) & vbcrlf
end if
next
|
|
|
|
|
|
|
|
|
|
|
|