Welcome to WebmasterWorld Guest from 22.214.171.124 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
for each... statement I know I've done this before? too much information
I'm really drawing a blank right now. I know I have used a 'for' statement before to process a form, something like:
for each variable_name
what's the syntax if I have several check boxes named the same thing in a form, and I need to process however many that my user checks off.
Thanks! I'm having a real brain cloud!
MyArray = Split(Request.Form("radioButtonName", ",")
For i=0 To Ubound(MyArray)
'test to see if checkbox selected
too much information
that could work. Thanks for the help.
For some reason I was not able to find any code where I had done this before. I guess I have too much code now! ;)
For Each MyCheckBox In MyArray
' Do whatever you need to do on MyCheckBox Next
Never seen that method before. Does a for..each work with arrays?
Smokins way is the one i'd use for this.
The way to process form collections in a for..each is :
for each control in request.form
This is slightly off-topic, but remember that when you look at the contents of the request object, order is unreliable. ie:
i = 0
For each Item In Request.Form i = i + 1
'***DON'T DO THIS ***
Response.Write(Request.Form.Key(Item) & " " & Request.Form(Item) & "<br>")
'***DO THIS INSTEAD ***
Response.Write(Request.Form.Key(i) & " " & Request.Form(Request.Form.Key(i)) & "<br>") Next
Or you'll get mismatched name/value pairs.
For...Each works with collections and the items that make up those collections. For instance:
'' oField will be an instance
'' of the Fields collection
For Each oField In oRecordset.Fields
Response.Write oField.Name & "<br>"
Hope that helps.
Oh...and no, I don't think this works with arrays because an array is not a collection. too much information
aspdaddy, that's exactly what I was looking for! You ROCK!
I knew I had seen that before I just couldn't find it in my piles of code. I guess I need to find a way to search my drive for statements and other cool things that my wife doesn't really want to know about! ;)