|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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>
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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? |
|
#5
|
|||
|
|||
|
Thanks kiteless you put me in the right direction, I found a bit of info here:
http://tutorial357.easycfm.com/ Thanks again |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Variables inside variables ?! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|