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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamically populating a textbox? and sending email conf.

Status
Not open for further replies.

devondago

Programmer
Jan 22, 2003
38
US
Hi

I am doing a registration form and I have a drop down menu where users can select a class. Once they have choosen their class from that drop down menu i want the description of the class to be displayed on the textbook i created. Further more once the user hits submit i want to capture in my database what class they chose..Also I am submitting the values to a table and need to send a confirmation email to myself and the user can someone tell me if I am doing this right or better yet guide me in the right direction?

..here is my form....all help will be appreciated....

<head>
<title>FMB Class Registration Form</title>
</head>
<cfparam name=&quot;action&quot; default=&quot;showform&quot;>
<cfset #adminemail# = &quot;ltrujillo@mhs.net&quot;>

<cfquery name=&quot;getab&quot; datasource=&quot;#application.datasource#&quot; dbtype=&quot;ODBC&quot;>
select * from westclreg order by class_id
</cfquery>
<cfoutput><form name=&quot;form1&quot; action=&quot;#query_string#&action=postform&quot; method=&quot;post&quot;></cfoutput>
<table border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; width=98%>
<tr>
<td colspan=&quot;2&quot;><P align=center><font face=&quot;Times New Roman&quot; size=&quot;5&quot; color=&quot;CC0000&quot;><STRONG>The
FMB<br>
Class Registration</STRONG></FONT></P>
<font size=2>
<P>For complete descriptions of classes, view our &quot;<B><A href=&quot;>Class
Descriptions</A></B>.&quot; For dates and times, view our &quot;<B><A href=&quot;&quot;>Calendar</A></B>.&quot;
</p>
<p>It is necessary to register for all classes. Please call xxxxxxxxxx
or complete our E-mail refistration form below. We will confirm your registration
by phone or E-mail. We look forward to hearing from you! </p>
</font> <hr> <P align=center><font face=&quot;Times New Roman&quot; size=&quot;5&quot; color=&quot;CC0000&quot;><STRONG>
Class Registration</STRONG></FONT></P></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Name:</font></td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input type=&quot;text&quot; name=&quot;name&quot; size=&quot;26&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Email Address:</font></td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input type=&quot;text&quot; name=&quot;email&quot; size=&quot;26&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Telephon Number:</font></td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input type=&quot;text&quot; name=&quot;telephone&quot; size=&quot;26&quot; required=&quot;yes&quot; message=&quot;Telephone Number is required&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Altername Telephone:</td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input type=&quot;text&quot; name=&quot;alttelephone&quot; size=&quot;26&quot; required=&quot;yes&quot; message=&quot;Telephone Number is required&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Address:</td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input type=&quot;text&quot; name=&quot;address&quot; size=&quot;26&quot; message=&quot;Telephone Number is required&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>City:</td>
<td><font face=&quot;Verdena&quot; size=&quot;2&quot;><input name=&quot;city&quot; type&quot;text&quot; size=&quot;26&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Zip Code:</td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input name=&quot;zip&quot; type=&quot;text&quot; size=&quot;26&quot; required=&quot;yes&quot; message=&quot;Telephone Number is required&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Due Date:</font></td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;><input type=&quot;text&quot; name=&quot;duedate&quot; size=&quot;26&quot; required=&quot;yes&quot; message=&quot;Due Date is Required&quot;></font></td>
</tr>
<tr>
<td align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Class you want to regiter
for: </font></td>
<td><font face=&quot;Verdana&quot; size=&quot;2&quot;>
<select name=&quot;class&quot;>
<cfoutput query=&quot;getab&quot;>
<option value=&quot;#class_id#&quot; >#class#</option>
</cfoutput>
</select>
</font></td>
</tr>
<tr>
<td align=&quot;center&quot; colspan=&quot;2&quot;>&nbsp; </td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;center&quot; valign=&quot;top&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;>Class
Description:</font></td>
</tr>
<tr>
<td align=&quot;center&quot; colspan=&quot;2&quot;><textarea rows=&quot;10&quot; name=&quot;message&quot; cols=&quot;42&quot;>
#getab.description#</textarea></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=center><input type=&quot;submit&quot; value=&quot;SUBMIT REGISTRATION&quot;>
</form></td>
</tr>
</table>
<cfset name = &quot;&quot; >
<cfset email =&quot;&quot;>
<cfif #action# IS 'postform' >
<cfquery name=&quot;insdb&quot; datasource=&quot;west80139&quot; dbtype=&quot;ODBC&quot;>
insert into westreginfo
(name,email,telephone,alttelephone,address,city,zip,duedate,class)
values
('#name#','#email#','#telephone#','#alttelephone#','#address#','#city#','#zip#','#duedate#','#class#')
</cfquery>
<cfif #name# IS NOT 'test' >
<!--- <cfif #gen_em# IS NOT '' >--->
<cfmail to=&quot;#adminemail#&quot; from=&quot;laritrujillo@prodigy.net&quot; subject=&quot;Class Regiatration&quot;>
#name# has just submitted a class registration
<!--- <cfif #req# GREATER THAN 0 >
Requisition Number: #req# - #jdesc#
<cfelse>
User has requested to be considered for ANY job</cfif>--->
</cfmail>

</cfif>



<cfmail to=&quot;#email#&quot; from=&quot;#adminemail#&quot; subject=&quot;Your Class Registration Confirmation Email&quot; type=&quot;HTML&quot;>
<div align = center>
<IMG src=&quot;http:../images/mhslogoje.gif&quot; >
</div><br>
Dear #name#:
<p>
Thank you for registring to the FBC.
Your registration has been forwarded to our class specialist.
If you class is reschedule or canceled, you will be contacted
with other options.
<p>
Thank you,
<p><p><br>
FBC Registration<br>
Specialist, Family BirthPlace<br>
MHW<br>
<p>
<P>
<br>
<table width = 100% border=0>
<tr><th colspan = 2 align = left >Family BirthPlace Contact Numbers:</th></tr>
<tr><td width = 60%>MHW </td><td width = 40%>(xxx) xxx-xxxx</td></tr>
<tr><td width = 60%>MRH </td><td width = 40%>(954) xxx-xxxx</td></tr>
<tr><td width = 60%>MRH </td><td width = 40%>(954) xxx-xxxx</td></tr>
</table>

</cfmail>


<p align=center><font color=&quot;cc0000&quot; face=&quot;Verdana&quot; size=&quot;3&quot;><b>Thank you for submitting your registration.</font><p>

<div align=center>
<font face=&quot;Verdana&quot; color=&quot;003399&quot; size=&quot;2&quot;>
Your registration has been forwarded to our FBP Representative. </b></font>
<p>

<font face=&quot;Verdana&quot; color=&quot;003399&quot; size=&quot;2&quot;><a href=&quot;_javascript:this.close()&quot;>Click here</a> to close this window</font>
</div>

</body>
</html>

</cfif>

 
if you have all of the below on the same form then it will run the second the page is loaded and try to insert data into the database and send the email.

what I would do is to have a two stage process. The first stage is the collection of all of the details that you want from the form. This form will the submit to another page(stage two), where you will use the Form scope (Form.Class etc...) to access the values that were submitted from your form, to insert into your database and to send the email off.

your first page will be everything before:

<cfset name = &quot;&quot; >
<cfset email =&quot;&quot;>
<cfif #action# IS 'postform' >

and the seond page will be everything from there onwards.

You will need to change the action on your form to post the information to another page, instead of whatever is in the query_string at the moment.

As for the population of a text box. What I have done in the past is to create a javascript array of the information that I want to display, and then use
onChange=showDesc(this.value) on the select, so when the user changes the value in the drop down the javascript function is run and the data is pulled out. what you have to do is to populate the javascript array first using CF.

I'll try to dig some code out when I have a chance, or you could look around this forum I think it has been mentioned a few times!

Hope this helps!

Tony
 
Thanks for the input...If you can I would really appreciate the help with the code.

thanks

devondago
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top