Solved

Using a variable inside value

Posted on 2013-06-17
2
243 Views
Last Modified: 2013-06-18
I am trying to use cfloop to get data from database. I want to put data in the value inside input text tag.

MyVar is a variable and it goes from 1 to 5.
 
How can I get value from database.
 
<input name="AfterFunding#MyVar#T" type="text" value="#others.AfterFunding#MyVar#T#">

So this tag should be <input name="AfterFunding1T" type="text" value="#others.AfterFunding1T#"> and it goes until 5T. the name is working but the value doesn't recognize it because there are two sets of ##.
0
Comment
Question by:jkemple
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39256129
Use array notation. Since it's a query object, you'll also need to supply a query row number

ie       #queryName["someFixedName"& counterVariableHere ][ rowNumber ]


.. translated, something like this, where "1" is the first row of the query

     value="#others["AfterFunding"& MyVar &"T"][1]#"

... or you're using cfloop query, use currentRow instead of hard coding the row number

<cfloop query="others">
     <input value="#others["AfterFunding"& MyVar &"T"][ currentRow]#" ....>
</cfloop>
0
 

Author Closing Comment

by:jkemple
ID: 39257126
Thank you. It works.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
use of cookies and regulations 1 103
ColdFusion How can I sort my CF Directory output by main directory then sub folders - files? 12 53
REGEX HELP 11 57
How to build a web site 17 53
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question