Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile looping through checkboxes on a form

    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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    This loops through the checkboxes named check1, check2, check3, ...check19.
    Code:
    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
    next


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •