[thelist] ASP Loop Question

Chris Blessing webguy at mail.rit.edu
Wed Mar 20 10:17:00 CST 2002


Josh-

You are walking the fine line between object (variable) names and literal
values.  Here's the deal: when you say request.form("name"), you're actually
going to get a value for a variable.  That "variable" is an item in the
request() collection object.

However if you try to get the value for "variable_" & x, that is a literal
value which is not associated with an object/variable name.  Thusly you will
get "variable_1" etc.

This is why you would use the eval() function.  It takes a string literal
and returns the value of the variable with that name.  So eval("variable_" &
x) would work, since it's returning the value associated with the object
named variable_x.

HTH!

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net

> While we are on this subject, it is interesting to note that
>
> <%
> for x = 1 to 2
> 	variable = request.form("variable_" & x  )
> next
> %>
>
> works, whereas
>
> <%
> for x = 1 to 2
> 	variable = "variable_" & x
> next
> %>
>
> does not.
>
> I wonder why.
>
> Josh




More information about the thelist mailing list