ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 27th, 2005, 07:24 AM
simonl simonl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: UK
Posts: 16 simonl User rank is Private First Class (20 - 50 Reputation Level)simonl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 3 m 3 sec
Reputation Power: 0
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...

Reply With Quote
  #2  
Old July 27th, 2005, 08:26 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old July 27th, 2005, 08:42 AM
simonl simonl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: UK
Posts: 16 simonl User rank is Private First Class (20 - 50 Reputation Level)simonl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 3 m 3 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old July 27th, 2005, 10:19 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
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>

Reply With Quote
  #5  
Old July 27th, 2005, 12:52 PM
simonl simonl is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: UK
Posts: 16 simonl User rank is Private First Class (20 - 50 Reputation Level)simonl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 3 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
Still you can do it using the syntax I gave before:
<cfoutput>#form['name_#loopCount#']#</cfoutput>


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.

Reply With Quote
  #6  
Old July 27th, 2005, 01:25 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Varable Post Varables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT