Solved

Dynamic Variable Name

Posted on 2004-04-16
10
430 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
  • 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Join & Write a Comment

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now