View Full Version : Problem with For/Next Loop...

09-07-2007, 10:20 PM
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>"


09-07-2007, 11:00 PM
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.

09-07-2007, 11:37 PM
No dice. Still updates only the first record. I have to be missing something simple.

09-08-2007, 01:46 AM
Silly question -- Are all the checkboxes that you want to update named "chkBox"