We help IT Professionals succeed at work.

coldfusion form.fieldname evaluation

tw67jw
tw67jw asked
on
310 Views
Last Modified: 2011-10-03
I am trying to take the incomming form variables that begin with an underscore and use the variable name and it
value but I get an error message saying element I is undefined in form.
Here is the code
 
<cfoutput>
<cfmail from= #form.Email# to="twalker@calhealth.org;" subject="CSHE MEMBERSHIP APPLICATION"><!--- <cfabort> --->
 
Event....................#form.Event##chr(13)#
Membership...............#form.Membership##chr(13)#
First Name...............#form.FirstName##chr(13)#
Last Name................#form.LastName##chr(13)#
Middle Initial...........#form.MiddleInitial##chr(13)#
Title....................#form.Title##chr(13)#
Employer.................#form.Employer##chr(13)#
Employers Address........#form.EmployerAddress##chr(13)#
Employers City...........#form.EmployerCity##chr(13)#
Employers State..........#form.EmployerState##chr(13)#
Employers ZipCode........#form.EmployerZipCode##chr(13)#
Phone Number.............(#form.EmployerPhone1# ) #form.EmployerPhone2# - #form.EmployerPhone3##chr(13)#
fax Number...............(#form.Employerfax1# ) #form.Employerfax2# - #form.Employerfax3##chr(13)#
Address..................#form.mailingAddress##chr(13)#
City.....................#form.mailingCity##chr(13)#
State....................#form.mailingState##chr(13)#
ZipCode..................#form.mailingZipCode##chr(13)#
E-Mail...................#form.Email##chr(13)##chr(13)#
Credit Card#chr(13)#
Credit Card Type..........#form.cctype##chr(13)#
Full Name on Card.........#form.ccname##chr(13)#
Credit Card Number........#form.ccnum##chr(13)#
Expiration Date...........#form.ccemonth#/#cceyear##chr(13)#
Amount to charge..........#form.txCharge##chr(13)#
Item Checked....#chr(13)#
<cfloop list="#form.fieldnames#" index="i">
	<cfif left(i,1) eq "_">
		#right(i,len(i)-1)# - #form.i# #chr(13)#
	</cfif>
</cfloop>
<cfif isdefined("form.txaAdditionalRegistrants")>
Additional Registrants....#chr(13)#
#form.txaAdditionalRegistrants#
</cfif>
</cfmail>
</cfoutput>
<cflocation url="aithanks.html">
 
if I change it as shown below it runs but the evaluation comes out just showing the form field name (form.fieldname) instead
of the value of form.fieldname
 
Item Checked....#chr(13)#
<cfloop list="#form.fieldnames#" index="i">
	<cfif left(i,1) eq "_">
		<cfset ev = "form." & #i#>
		#right(i,len(i)-1)# - #de(ev)# #chr(13)#
	</cfif>
</cfloop>

Open in new window

Comment
Watch Question

erikTsomikSystem Architect, CF programmer

Commented:
try using <cfparam name="form.formElementname" default="">

Author

Commented:
I only want the fieldNames that begin with an underscore - did you notice the <cfloop> where I walk throught the form fieldnames and select only those that begin with an underscore? I need to evaluate it at that point...
CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
Also, I would strongly suggest against emailing credit card information.  

Author

Commented:
I agree but needed a quick fix... thanks for the help.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.