forms collection and for next

M

Mats

I'm trying out some code cause of an idea I just got, but it won't work
for each item in Request.Form
Response.Write (Request.Form("item"))
Response.Write("<br>")
next
only one <br> per Request.Form("item") appears on the page, but no item
in Request.Form is written.
However I've learnt that "You can iterate through a collection using a
For Each item in ... Next loop."

Mats
 
B

Bob Barrows

Mats said:
I'm trying out some code cause of an idea I just got, but it won't
work for each item in Request.Form
Response.Write (Request.Form("item"))

You just told it to write the contents of a variable called "item". I doubt
there is a variable with that name in your Forms collection.

What you really wanted it to do was write the contents of the variable whose
name is contained in the item variable. Like this*:

Response.Write Request.Form(item)

* You should not use the parentheses around the response.write argument -
the Write method does not return a value, so the parentheses are not needed
unless you are doing this in jscript.

HTH,
Bob Barrows
 
E

Evertjan.

Mats wrote on 20 sep 2003 in microsoft.public.inetserver.asp.general:
I'm trying out some code cause of an idea I just got, but it won't work
for each item in Request.Form
Response.Write (Request.Form("item"))
Response.Write("<br>")
next
only one <br> per Request.Form("item") appears on the page, but no item
in Request.Form is written.
However I've learnt that "You can iterate through a collection using a
For Each item in ... Next loop."

<%
for each item in Request.form
Response.Write item & " = " & Request.form(item) & "<br>"
next
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,104
Messages
2,570,643
Members
47,248
Latest member
Angelita78

Latest Threads

Top