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 June 12th, 2005, 12:09 PM
airdesign airdesign is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Oxford, UK
Posts: 93 airdesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 12 m 51 sec
Reputation Power: 4
Send a message via MSN to airdesign Send a message via Yahoo to airdesign
Variables inside variables ?!

This bit of code below is part of a system's settings update management system.

The code in bold is where the problem lies:
The form that submits to this page dynamically outputs 'form inputs' on a page, each input has it's own 'name attribute' which is the same as the database's setting ID.

The difficulty I'm having is, I'm looping over each setting, one by one -> and updating that setting's property in the database. The problem is I need a variable inside another one! I need the variable of the loop's index to find out the variable of the form's input's value.

I home someone can help.

Cheers

Code:
<cfquery name="getSettings" datasource="luciddream">
SELECT * FROM Settings ORDER BY OrderNo ASC
</cfquery>

	<cfloop from="1" to="#getSettings.recordcount#" index="index">
				<cfquery name="getSettings" datasource="luciddream">
					UPDATE Settings SET Property = 'Form.#index#.value' WHERE ID = #index#
				</cfquery>
	
	</cfloop>

<script>alert('Changes were made!');</script>

Reply With Quote
  #2  
Old June 12th, 2005, 12:14 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
You can use structure notation to do this.

#form[index].value#
__________________
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 June 12th, 2005, 12:19 PM
airdesign airdesign is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Oxford, UK
Posts: 93 airdesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 12 m 51 sec
Reputation Power: 4
Send a message via MSN to airdesign Send a message via Yahoo to airdesign
I'm familiar using this with querying recordsets from SELECT[ions] but how would I implement that method with the code I've already got.


Code:
<cfoutput query="getSettings">
				<cfquery name="saveSettings" datasource="luciddream">
					UPDATE Settings SET Property = '#Form[getSettings.ID]#' WHERE ID = #index#
				</cfquery>
	
	</cfoutput>


I tried that code and I knew it was going to throw an error

If only I could do the following:
Code:
<cfset valueID2update = form.#getsettings.id#>


What would I do kiteless?

Cheers

Reply With Quote
  #4  
Old June 12th, 2005, 02:02 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
What exactly do you want the final evaluated variable to look like? That is the key to figuring out what you need to do. According to your first post, inside the loop the variable would look like this:

Form.1.value, then Form.2.value, etc., as the loop iterates. Is that what you really want?

Reply With Quote
  #5  
Old June 12th, 2005, 04:40 PM
airdesign airdesign is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Oxford, UK
Posts: 93 airdesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 12 m 51 sec
Reputation Power: 4
Send a message via MSN to airdesign Send a message via Yahoo to airdesign
Thanks kiteless you put me in the right direction, I found a bit of info here:
http://tutorial357.easycfm.com/

Thanks again

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Variables inside variables ?!


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