Helpful Information
 
 
Category: ColdFusion Development
Email Form - Beginner

I am new to cold fusion and have limited skills. My email form is working in a basic sense. I am getting an error at the bottom of my page, but I can still enter information and it emails the information correctly.

The error is:
--------------------------------------------------------------------------------
Error Diagnostic Information
An error occurred while evaluating the expression:
#Form.Hear#
Error near line 113, column 46.
Error resolving parameter FORM.HEAR
The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name.
The error occurred while processing an element with a general identifier of (#Form.Hear#), occupying document position (113:45) to (113:55).

--------------------------------------------------------------------------------

I also get an error when I don't fill in the checkbox and it DOES NOT email the information correctly in this case. The error is:

--------------------------------------------------------------------------------
Error Diagnostic Information

An error occurred while evaluating the expression:
#Form.Credentials#
Error near line 117, column 15.
Error resolving parameter FORM.CREDENTIALS
The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name.
The error occurred while processing an element with a general identifier of (#Form.Credentials#), occupying document position (117:14) to (117:31).


--------------------------------------------------------------------------------


It appears I need to setup some coding so if no information is answered in the checkbox question the form still is submitted without an error.

Lastly, I want to redirect the page once the information/form is submitted to a new website page:
http://jumpstart-l.puttinontheweb.com/scripts/wa.exe?SUBED1=jumpstart&A=1

If there is a tutorial that explains these very things, please let me know. I did look at several tutorials but nothing covered exactly what I wanted.

My coding for the form is below. Thanks for your help.

Teresa

Cold Fusion Coding
--------------------------------------------------------------------------------

<CFMAIL FROM="terepan@yahoo.com" TO="terepan@yahoo.com" SUBJECT="Jump Start Listserv Form">

A user signed up for the Jump Start Listserv.

Where user heard about Jump Start Listserv: #Form.Hear#
If completed Other: #Form.HearOther#
Area of Practice: #Form.Practice#
If completed Other: #Form.PracticeOther#
Credentials: #Form.Credentials#
If completed Other: #Form.CredentialsOther#

</CFMAIL>

--------------------------------------------------------------------------------

Form Coding (I actually have this above the CFMAIL coding):

--------------------------------------------------------------------------------

<form method="post" action="index.cfm">
<table border="0" cellpadding="1" cellspacing="1" class="label" align="left" width="396">
<tr align="left" valign="top">
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">Where
did you hear about the Jump Start listserv? </font> </td>
</tr>
<tr align="left" valign="top">
<td colspan="2">
<p>
<select name="Hear">
<option selected>Please select one</option>
<option value="Listserv">Another Listserv</option>
<option value="Borchure">Brochure</option>
<option value="Seminar">Seminar</option>
<option value="Self-study">Self-study Product</option>
<option value="Conference-Tradeshow">Conference or Trade Show</option>
<option value="Colleague">Colleague</option>
<option value="Other">Other</option>
</select>
</p>
<p><font face="Arial, Helvetica, sans-serif" size="2">If Other:
<input type="text" name="HearOther">
</font></p>
<p>&nbsp; </p>
</td>
</tr>
<tr align="left" valign="top">
<td colspan="2">
<p><font size="2" face="Arial, Helvetica, sans-serif">Which best
describes your practice area?</font></p>
</td>
</tr>
<tr align="left" valign="top">
<td colspan="2">
<p>
<select name="Practice">
<option selected>Please select one</option>
<option value="Clinical">Clinical--Hospital or Ambulatory</option>
<option value="Foodservice">Foodservice</option>
<option value="Marketing">Marketing and Communications</option>
<option value="PublicHealth">Public Health</option>
<option value="College">College or University</option>
<option value="PrivatePractice">Private Practice, General</option>
<option value="SportsExercise">Sports and Exercise</option>
<option value="CorporateWellness">Corporate Wellness</option>
<option value="OccupationalHealth">Occupational Health</option>
<option value="EatingDisorders">Eating Disorders</option>
<option value="Diabetes">Diabetes</option>
<option value="Other">Other</option>
</select>
</p>
<p><font face="Arial, Helvetica, sans-serif" size="2">If Other:
<input type="text" name="PracticeOther">
</font></p>
<p>&nbsp; </p>
</td>
</tr>
<tr align="left" valign="top">
<td colspan="2">
<p><font face="Arial, Helvetica, sans-serif" size="2">Credentials
(please select one):</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="2">
<input type="checkbox" name="Credentials" value="RD">
RD<br>
<input type="checkbox" name="Credentials" value="RN">
RN<br>
<input type="checkbox" name="Credentials" value="MS">
MS<br>
<input type="checkbox" name="Credentials" value="PhD">
PhD<br>
<input type="checkbox" name="Credentials" value="None">
None<br>
<input type="checkbox" name="Credentials" value="Other">
Other, <em>please specifiy below</em><br>
<br>
<br>
Other:
<input type="text" name="CredentialsOther">
</font></p>
</td>
</tr>
<tr align="left" valign="top">
<td colspan="2">
<div align="left">
<input type="submit" value="Submit" name="submit">
</div>
</td>
</tr>
</table>
</form>

I take it that the <cfmail> block is only evaluated when the form fields are available, ie: after form submital? If not, it's what's causing your problem. I'll show you the easiest way to do this.

Regarding the checkbox, the problem is due to the fact that if no box is checked, the variable will not be present on the target page. The easiest wat to fix this, in your case, would be to use radio buttons for the Credentials element instead. It's of course possible to keep using a checkbox if you'd like, but I think radio buttons are more appropriate for this particular question in any case.

In your case the easiest way to do the redirect is probably with cflocation (http://livedocs.macromedia.com/cfmxdocs/CFML_Reference/Tags-pt166.jsp#1100753).

Altered Credentials form element:


<p><font face="Arial, Helvetica, sans-serif" size="2">Credentials
(please select one):</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="2">
<input type="radio" name="Credentials" value="RD">
RD<br>
<input type="radio" name="Credentials" value="RN">
RN<br>
<input type="radio" name="Credentials" value="MS">
MS<br>
<input type="radio" name="Credentials" value="PhD">
PhD<br>
<input type="radio" name="Credentials" value="None">
None<br>
<input type="radio" name="Credentials" value="Other">


For whatever value you want to be the default, add selected="selected" to the input tag. It's important that you do this, otherwise, if the user forgets to choose one an error will be produced.

And for the cfmail section:


<cfif IsDefined("form.FieldNames")>

<cfmail>
...
</cfmail>

<cflocation url="http://jumpstart-l.puttinontheweb.com/scripts/wa.exe?SUBED1=jumpstart&A=1" addToken="no" />

</cfif>



Good luck!

It worked!!

Thanks for your patience and help!

Teresa

No problem, glad to hear you got it sorted! Happy CF'ing :)

Hey CFgeek - good job! ;)

Originally posted by Jcaputo
Hey CFgeek - good job! ;)

Hey, I'm just glad to post in thread that isn't a CF v PHP flame war ;)

Originally posted by cfgeek
Hey, I'm just glad to post in thread that isn't a CF v PHP flame war ;)

Agreed - There should be a moratorium on Language vs. Language flame wars on Devshed, unless of course you're posting in the Lounge.

Oh - bashing C#/VB/ASP/.NET is OK, tho - its always open season on those guys. :D (j/k)










privacy (GDPR)