This content has been marked as final.
Show 6 replies
-
1. Re: Dynamic CFInput Names Using Arrays
dave.cozens Oct 30, 2006 9:40 AM (in response to kodemonki)At this point you haven't actually got any array values set. What you're doing is creating a form field with the name parameter set to #reasonArray[report_id]#". This array has not been populated with anything, so it's failing.
What are you trying to achieve? -
2. Re: Dynamic CFInput Names Using Arrays
kodemonki Oct 30, 2006 9:46 AM (in response to dave.cozens)I'm trying to set the array index equal to the value entered in the textbox. Later I need to send an e-mail that goes through each report id, sees if it's been selected, and if it has, lists the reason for that report.
Please let me know if this still isn't clear.
Thank you! -
3. Re: Dynamic CFInput Names Using Arrays
jdeline Oct 30, 2006 9:56 AM (in response to kodemonki)In my experience, you must directly populate an array element with an assignment. You might try the following: name="R#report_id#" In your action page, you can easiely assign the Rnnn to the reasonArray, using nnn as the index into the array.
BTW, you have a logic error in the first part of your code. If the <CFIF> statement is FALSE, you do not get the <TR tag, and style="font-size:11;"> is hanging out. -
4. Re: Dynamic CFInput Names Using Arrays
dave.cozens Oct 30, 2006 9:58 AM (in response to kodemonki)OK, so the array serves no purpose on the form page, since you don't yet have any data. You need that on the action page.
Hopefully this will give you some pointers...
Form Page
<Cfoutput query="getReports">
<input type="text" name="data_#getReports.report_ID#">
<inputy type="hidden" name="report_ids" value="#report_id#">
</cfoutput>
Action Page
<Cfloop list="#report_ids#" index="report_id">
<cfset thisReportData=form["data_"&report_id]>
<cfoutput><br>#report_id# = #thisReportData#</cfoutput>
</cfloop> -
5. Re: Dynamic CFInput Names Using Arrays
kodemonki Oct 30, 2006 10:20 AM (in response to dave.cozens)Thank you so much! That was actually my backup solution that I've been using, but it doesn't work without the form[] so I've been writing everything out, which defeats the whole purpose of dynamic code. Do you know where I can find documentation on that part?
Also, jdeline, thanks for your comment about the logic error. I edited a lot of the unnecessary code to make the post more readable and turns out it was just more confusing. Thanks though! -
6. Re: Dynamic CFInput Names Using Arrays
dave.cozens Oct 30, 2006 10:29 AM (in response to kodemonki)Honestly I'm not sure about the documentation part.
Basically, there's no difference between: -
form.my_field and form["my_field"]
They both reference the same value. But the array style notation is much more versatile and totally dynamic (plus avoids using evaluate - which is what we had to do many years ago!)
You can do the same thing with all the variable scopes
session["myStructure"].myValue
Use cfdump to see more, for example
<cfdump var="#server#">
<cfdump var="#variables#">
<cfdump var="#form#">