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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with For/Next Loop...

    What about the following code would make it only process the first checkbox value it encounters and no subsequent ones (ie. I check five checkboxes and it only processes the first one it encounters? All the values are showing up as expected when I use response.write arrVals(i) & "<br>" to view the values that are running through the loop.... it just won't update all of them... only the first one it comes to.

    arrVals = split(Request.Form ("chkBox"), ",")

    'loop through the checkboxes which were ticked
    FOR i = 0 to ubound(arrVals)

    'Update the Category Code for the items selected
    objRst.Open "UPDATE MyDatabase SET Field1 = '"& strCatCode &"' WHERE Field2 = '"& arrVals(i) &"' "

    response.write arrVals(i) & "<br>"

    NEXT
    Last edited by sladerwilson; 09-07-2007 at 11:26 PM.

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Try arrVals = split(Request.Form("chkBox"), ", ")

    When HTML posts Checkbox values, it adds the extra white space on the end.

    Also, do a Connection.Execute (where Connection == what ever your database connection is), not an objRst.Open.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No dice. Still updates only the first record. I have to be missing something simple.

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Silly question -- Are all the checkboxes that you want to update named "chkBox"
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.


  •  

    Posting Permissions

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