Solved

Dynamic Variable Name

Posted on 2004-04-16
10
454 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iis reverse proxy virtual directory 8 172
Systems talking to each other 5 130
change time in cron 4 78
How to best troubleshoot slow internet connections via proxy server? 2 81
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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