Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating & Accessing Dynamic Variables

Status
Not open for further replies.

varnix

Programmer
Joined
Jan 7, 2002
Messages
94
Location
US
In one of my CF pages I need to create a form field using two seperate query results as the name. There are multiple sets of the fields and the name consists of the company code and the employee number.

We have two seperate divisions with seperate company codes and duplication of employee numbers, hence the complicated name creation scheme - here is the code:

<input type=&quot;radio&quot; name=&quot;#companycode##employeenumber#&quot; value=&quot;1&quot;>Approved
<input type=&quot;radio&quot; name=&quot;#companycode##employeenumber#&quot; value=&quot;2&quot;>Denied
<input type=&quot;radio&quot; value=&quot;0&quot; checked name=&quot;#companycode##employeenumber#&quot;>No Change

This is part of a form that calls the next CF page where we need to process each of the sets of radio buttons.

The problem that I am experiences is that while I can recreate the name, for example a company code of 10 and an employee number of 1404 becomes '101404'. I simply cannot access the data stored within the form variable.

I've been trying things such as:
#form.#companycode##employeenumber##

This is in an effort to recreate the form field name of #form.101404# which would have a value of 0,1 or 2.

Unfortunately all I ever seem to end up with is setting the field in the DB to &quot;form.101404&quot; not the value of the field, but the actual text as shown.

I know how to create these types of dynamic names and access them in CGI/PERL, but so far it is eluding me in Cold Fusion.

Any suggestions are appreciated.
 
I did some testing and apparently, the name of a form variable must begin with a alphabetic character. Once you have changed that, use the evaluate() function.

<form method=&quot;post&quot;>
<input type=&quot;radio&quot; name=&quot;a#companycode##employeenumber#&quot; value=&quot;1&quot;>Approved<br>
<input type=&quot;radio&quot; name=&quot;a#companycode##employeenumber#&quot; value=&quot;2&quot;>Denied<br>
<input type=&quot;radio&quot; value=&quot;0&quot; checked name=&quot;a#companycode##employeenumber#&quot;>No Change<br>
</form>

Then on the page that processes the form:

#evaluate(&quot;a#companycode##employeenumber#&quot;)#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top