homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

for each... statement
I know I've done this before?
too much information

 11:42 pm on Jul 30, 2003 (gmt 0)

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!



 12:08 am on Jul 31, 2003 (gmt 0)

MyArray = Split(Request.Form("radioButtonName", ",")

For i=0 To Ubound(MyArray)

'test to see if checkbox selected


too much information

 12:20 pm on Jul 31, 2003 (gmt 0)

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! ;)


 1:02 pm on Jul 31, 2003 (gmt 0)

For Each MyCheckBox In MyArray
' Do whatever you need to do on MyCheckBox



 1:10 pm on Jul 31, 2003 (gmt 0)

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

// name
response.write control

// value
response.write request(control)



 6:15 pm on Jul 31, 2003 (gmt 0)

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>")

Response.Write(Request.Form.Key(i) & " " & Request.Form(Request.Form.Key(i)) & "<br>")

Or you'll get mismatched name/value pairs.


 9:42 pm on Jul 31, 2003 (gmt 0)

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.


 9:44 pm on Jul 31, 2003 (gmt 0)

Oh...and no, I don't think this works with arrays because an array is not a collection.

too much information

 2:48 am on Aug 1, 2003 (gmt 0)

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! ;)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved