troubleshooting Question

ColdFusion - How do I output dynamic form variables?

Avatar of makila
makila asked on
Web Development SoftwareWeb Servers
6 Comments1 Solution1159 ViewsLast Modified:
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">
                  <b>user</b>
            </td>
            <td align="center" width="200" class="small">
                  <b>current balance</b>
            </td>
            <td align="center" width="200" class="small">
                  <b>add to balance</b>
            </td>
      </tr>
      <cfloop query="qryAM_Balances">
            <cfif intBgColor is 0>
                  <cfset intBgColor = 1>
                  <cfset strbgcolor = "##FFFFFF">
            <cfelse>
                  <cfset intBgColor = 0>
                  <cfset strBgColor = "##E5E5E5">
            </cfif>
      <tr align="left" valign="center" bgcolor="<cfoutput>#strBgColor#</cfoutput>" class="tiny">
            <td>
                  <cfoutput>#lcase(qryAM_Balances.Rep_Name)#</cfoutput>
            </td>
            <td align="center">
                  <cfoutput>#lcase(qryAM_Balances.Current_Balance)#</cfoutput>
            </td>
            <td align="center">
                  <input type="text" name="<cfoutput>#qryAM_Balances.NT_ID#</cfoutput>_ADD" value="0" size="3">
            </td>
      </tr>
      </cfloop>
</table>
<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">
            </td>
      </tr>
</table>
</FORM>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros