Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamic Variable Name

Posted on 2004-04-16
10
Medium Priority
?
508 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 2000 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

926 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