Solved

Dynamic Variable Name

Posted on 2004-04-16
10
492 Views
Last Modified: 2013-12-24
Hello,

I trying to solve a small problem here. I've got a form, which is used for updating information in a database. This form makes a field with it's name derived from the ID, like this:

<input type="text" name="field_#ID#" value=......>

After submitting I'd like to read the value that is in field_#ID# one by one. However I'm unable to read it. Things like #field_##ID# don't work of course, but other things I tried don't work either.

Can someone tell me how to get the data from the fields?
0
Comment
Question by:ekurvers
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 25

Expert Comment

by:James Rodgers
ID: 10841855
try

#evaluate("field_"#id#)#
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
ID: 10841891
sory

should be

evaluate("form.field_#idx#")   <-- quote was out of place in the first post
0
 
LVL 1

Author Comment

by:ekurvers
ID: 10841980
That was really close and helped me find it. Thanks for that one, the correct version is:

#evaluate("field_#id#")#

This way it handles the field_#id# as part of the evaluation string.

Thanks,
Eelco
0
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
LVL 1

Author Comment

by:ekurvers
ID: 10841986
Sorry,

You already corrected it :D
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 10842023
glad i could help

thanks for the points
0
 
LVL 1

Author Comment

by:ekurvers
ID: 10842169
You're welcome
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10843980
Also consider using :

#Form['field_' & id]#

which is more efficient than the evaluate syntax and works in places the evaluate syntax does not.
0
 

Expert Comment

by:MsReba
ID: 10855079
I am having a similar problem. I am dynamically creating input checkboxes with the following query:
<cfquery name="getModels1" datasource="#DSN#" username="#UN#" password="#PW#">
SELECT tblModel.Model_id, tblModel.Model, tbl.Model.Comp_id, tblCompanies.Comp_id, tblModel.BitValue, tblCompanies.CompName
FROM tblModel,tblCompanies
WHERE tblModel.Comp_id = 1 and tblCompanies.Comp_id = 1
</cfquery>
<cfoutput query="getModels1">
<input type="checkbox" name="yachts" value="#Model#">#Model#<br></cfoutput>

I want to use the submitted variables in a cfmail to display the requested yacht information. I have tried numerous methods including #evaluate(form.yachts)# and the other examples. I have tried ListQualify, list loops ect and it is just a complete nightmare for me. Can anyone help?

Thanks,
Reba
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 10858562
this should really another question but....

<cfoutput query="getModels1">
<input type="checkbox" name="yachts_#getModels1.currentRow#" value="#Model#">#Model#<br></cfoutput>


and this will loop through the form


<CFIF ISDefined("Form.Fieldnames")>
  <table border="1">
    <CFOUTPUT>
      <CFLOOP Index="FieldName" List="#Form.Fieldnames#">
        <tr><td>Form.#FieldName#</td> <td>#Evaluate(FieldName)#&nbsp;</td></tr>
      </CFLOOP>
    </CFOUTPUT>
  </table>
</CFIF>
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10861440
MsReba,

Please post this as a separate question
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 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