简体   繁体   中英

coldfusion: display form value using variable

Coming from a form page, I have the following value: test1, test2, test3.. test50.

To display 1 of them, I can do this

<output> #form.test1# </output>

But I want to display all of them using a loop, how would I do it?

<cfloop index="i" from="1" to="#form.build_found#" >
    <output> #form.testi# </output>
</cfloop>

That should work:

<cfoutput>
   <cfloop index="i" from="1" to="#form.build_found#" >
        #form["test" & i ]# 
   </cfloop>
</cfoutput>

A few cfml coders might tend to use the evaluate() function. Don't use it, because it opens security holes in code like that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM