Solved

Using a variable inside value

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

729 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