Solved

Dynamic Variable Name

Posted on 2004-04-16
10
480 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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
What You Need to Know when Searching for a Webhost Provider
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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