WeCodeThings Library
Library of code bits
Glossary    Contact Us
Need a web designer? visit WeCodeThings.Com for more details
Search  
   
Browse by Category


WeCodeThings Library .: ColdFusion .: ColdFusion Create Unknown Amount of TextBoxes, or Radio buttons Dynamically by using Evaluate



ColdFusion Create Unknown Amount of TextBoxes, or Radio buttons Dynamically by using Evaluate

I was tasked with having to create an unknown amount of textboxes dynamically with ColdFusion.

I was running into a lot of problems because something like this:

  1. <cfloop index="i" from="1" to="#numberoftextboxes#">
  2.         <cfset myvar = FORM."txtbox_"&#i# />
  3.         <cfoutput>
  4.                 #myvar#
  5.         </cfoutput>
  6. </cfloop>

 

DOESN’T Work!

 

For this to work you need to use the EVALUATE function in ColdFusion. Create something like this:

  1. <cfloop index="i" from="1" to="#numberoftextboxes#">
  2.         <cfset myvar = Evaluate( "FORM.txtbox_#i#" ) />
  3.         <cfoutput>
  4.                 #myvar#
  5.         </cfoutput>
  6. </cfloop>

 

If I have create 15 text boxes dynamically created, then submit the form, I can loop over all of them like I did above and it will give me the value of what was entered into each of the 15 text boxes.

 

Ben Nadel gives a little more detail with a few more examples about creating dynamic variables here:
http://www.bennadel.com/blog/152-Dynamic-ColdFusion-Variables-Via-Quoted-Naming.htm



How helpful was this article to you?

Related Articles

article Flex 3 Create Remote Object Destination ColdFusion using ActionScript And MXML Flex 3
You can read more about Flex 3 and Remote...

(No rating)  4-30-2009    Views: 1154   
article Create Flex 3 Remote Object ColdFusion with Result and Fault Handlers for Flex 3
More about creating a remote object and...

(No rating)  4-28-2009    Views: 1425   
article Create Hyperlink to external or internal website in Flex 3 using LinkButton
The best way that I have found out to...

  4-9-2009    Views: 5237   

User Comments

Add Comment
No comments have been posted.




.: Powered by Lore .:Code by WeCodeThings Website Design and Development