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
Solved

Using a variable inside value

Posted on 2013-06-17
2
242 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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 …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

856 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