ColdFusion - How do I output dynamic form variables?

I have a form where I loop through a query to list all users that are labeled managers in a database. Each manager then has an input box where I can enter a number to increase their balance. I cannot figure out how to output the number I enter into the input box. I did not hard code each managers name because the number of managers is always changing.
Basically, each manager's variable name is their NT login with "_ADD" after it (i.e. JDoe_ADD) and that variable would equal a whole number. I tried to use <cfoutput>#<cfoutput>#qryAM_Balances.NT_ID#</cfoutput>_ADD#</cfoutput> but it came back with an error. I tried <cfoutput>##<cfoutput>#qryAM_Balances.NT_ID#</cfoutput>_ADD##</cfoutput> but then it just listed the variable name instead of the value.

Here is the code:

<FORM action="jackbucks_balances_II.cfm" method="post">                  
<table width="600" border="0" cellspacing="0" cellpadding="1">
      <tr align="left" valign="top" bgcolor="#FFCC00" class="tinywhite">
            <td width="200" class="small">
            <td align="center" width="200" class="small">
                  <b>current balance</b>
            <td align="center" width="200" class="small">
                  <b>add to balance</b>
      <cfloop query="qryAM_Balances">
            <cfif intBgColor is 0>
                  <cfset intBgColor = 1>
                  <cfset strbgcolor = "##FFFFFF">
                  <cfset intBgColor = 0>
                  <cfset strBgColor = "##E5E5E5">
      <tr align="left" valign="center" bgcolor="<cfoutput>#strBgColor#</cfoutput>" class="tiny">
            <td align="center">
            <td align="center">
                  <input type="text" name="<cfoutput>#qryAM_Balances.NT_ID#</cfoutput>_ADD" value="0" size="3">
<table width="600" border="0" cellspacing="0" cellpadding="1">
      <tr align="right">
            <td align="right">
                  <INPUT type="submit" value="add"> <INPUT type="reset" value="clear">
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

<cfoutput>#Form[qryAM_Balances.NT_ID & "_ADD"]#</cfoutput>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
makilaAuthor Commented:
I got the following error:

Element NT_ID is undefined in QRYAM_BALANCES

makilaAuthor Commented:
I figured it out. I needed to have the same query from the form page on the results page and I needed to loop it to get all the variables.

If I gave the form a name, would I be able to output the variable using the form's name instead of using "Form"?

Like this: <cfoutput>#Balance_Form[qryAM_Balances.NT_ID & "_ADD"]#</cfoutput>
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Well based on your code you have two choices.

1) send in the NT_ID value as a hidden variable
In that case you would access as:

<cfoutput>#Form[#Form.NI_ID_hidden#& "_ADD"]#</cfoutput>

2) Or you run the query again and then the error will go away.
>>If I gave the form a name, would I be able to output the variable using the form's name instead of using "Form"?

"Form" is not due to a lack of a name.  It is a scope.  Like Session

You are saying "look in the form scope for a variable of this name"

The name of the form is really useless unless you need it for dynamic javascript on the form page
makilaAuthor Commented:
Thanks for your help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.