|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Varable Post Varables
Does anyone have an answer!?
I am having trouble accessing varable post varables in CF. The posts that are being sent to the page are set as: name_1 name_2 etc etc. There are not always going to be a set amount of varables. I have got as far as looping the right amount time for the post data, but I can't access the var #name_1# etc... |
|
#2
|
|||
|
|||
|
Not sure exactly what you are asking. You can get a list of the form fields that were posted in form.fieldList. And given the name of a field you can get it's value like this #form[name_1]#
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Im trying to access the post varable like this, inside a loop
<cfset varable_name = "FORM.name_" & #loop_count#> <cfoutput>#varable_name#</cfoutput> Obviosly the second line will just output the name of the varable, not the content. I can't loop through form.fieldList as there are other varable as well. I can't hard write the post var name as there could be more in the future. I hope this is more clear. Thanks in advance. |
|
#4
|
|||
|
|||
|
I don't see why you can't just loop through the fieldlist...the only variables there are the ones posted from the form (except of course for fieldList).
Still you can do it using the syntax I gave before: <cfoutput>#form['name_#loopCount#']#</cfoutput> |
|
#5
|
|||
|
|||
|
Quote:
Thank you, that works. The reason that I couldn't loop through the fieldList is that there are other varables in the post like address_1, address_2, email_1, email_2 etc etc... and I want to access each set seperatly to put them to a database row. Thank again. |
|
#6
|
|||
|
|||
|
Could you not pass an additional hidden form field that told you, for example, there are 3 sets of fields (name_1, name_2, name_3) and then you'd know to loop 3 times and run your inserts? Or if you don't want to add that form field you could determine it yourself on the action page. Just a thought.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Varable Post Varables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|