Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form value using array?

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
CA
I am trying to create a variable from an array on my previous page.

page1.cfm ...

<form method="post" action="page2.cfm">
<CFLOOP INDEX="counter" FROM="1" TO="#ARRAYLEN(session.cart)#">
<input type="text" name="wrapit_#counter#" />
</CFLOOF>
</form>

page2.cfm ...

<CFLOOP INDEX="cart_count2" FROM="1" TO="#ArrayLen(session.cart)#">
<CFSET wrapit_temp = "form.wrapit_" & cart_count2>
<CFOUTPUT>
#wrapit_temp#<br />
</CFOUTPUT>
</CFLOOP>

I would like it to show the list of values BUT...
wrapit_temp comes out as "form.wrapit_temp" not the variable value.

Am I making sence?

Thanks for your help,

James
 
you're not setting the value of the variable you're looping through. try this.

<CFSET wrapit_temp = evaluate("form.wrapit_" & cart_count2)>

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Or, you could just output the variable directly:
Code:
<CFOUTPUT>
  <CFLOOP INDEX="cart_count2" FROM="1" TO="#ArrayLen(session.cart)#">
     #Form["wrapit_#cart_count2#"]#<br />
  </CFLOOP>
</CFOUTPUT>



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
ecobb's method is better. evaluate is kinda slow.

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top