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

To send email based on dropdown selection???

Status
Not open for further replies.

shruti18

MIS
Jun 22, 2005
30
US
Hello
I am trying to write a form which sends email on the basis of selection made in the drop down item of one the form fields.
So, there is an email address associated with every choice in the drop down. When the submit button of the form is clicked, the data of the form should be emailed to that corresponding email got from the selection made in the dropdown.
Could anyone suggest me how to do this?
Thanks!
 
Maybe this will help you out ....

Code:
<script language = "JavaScript">
<!--


function email( MailTo )

{
	window.location = "mailto:"+MailTo;
}


function change( )

{
	document.form.hidden1.value = document.form.name.value;
}


-->
</script>

<form name = "form">

<select name = "name" onChange = "change( );">
<option value="Nothing"></option>
<option value="Peter@aol.com">Pete</option>
<option value="Mikey@aol.com">Mike</option>
<option value="Jamie@aol.com">Jamie</option>

<input type = "hidden" name = "hidden1">


<INPUT type = "button" value = "submit" onClick = "email( this.form.hidden1.value );"> 

</form>

Let me know ...
 
I tried using ur code, but it gives an error at line
<input type="hidden" name="hidden1>
I have the form here:

<html>
<head>
<title>Contact</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><!-- START PAGE HERE --><!-- INSERT TEXT HERE -->
<body bgcolor="#FFFFFF" text="#000000" link="#000080" vlink="#FFFF00" alink="#000080">
<FORM NAME="form">
onSubmit="(document.mailer.action += mailtoandsubject)">
<div align="center"> <p>
<font face="Arial, Helvetica, sans-serif" size="5" color="#CC0000"><b>Department of Theatre Arts/<br> University of Pittsburgh Repertory Theatre</b><br> </font><font face="Arial, Helvetica, sans-serif" size="2">c/o University of Pittsburgh<br> 1617 Cathedral of Learning<br> Pittsburgh, PA 15260<br> <i>Phone: </i>412.624.6568<br> <i>Fax: </i>412.624.6338<br> </font></p></div>
<div align="center">
<p><font face="Arial, Helvetica, sans-serif" size="2">Or feel free to fill out the following form for specific questions:</font></p>
<I>* Required Fields</I><br><br>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2"> Interests:*</font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<SELECT NAME="name" onChange = "change( );">
<option value="jsw17@pitt.edu"> Graduate Admissions
<option value="anchor+@pitt.edu"> Undergraduated Studies
<option value="bamco+@pitt.edu">Graduate Studies
<option value="cia1@pitt.edu">Costumes
<option value="ylp1@pitt.edu">Communications
<option value="kek30@pitt.edu">Scene Shop/Prop Construction
<option value="er13@pitt.edu">Box Office
<option value="kspitz@pitt.edu">Artistic and Education Program
<option value="venise@pitt.edu">Costume/Accessory Design
<option value="lpt1@pitt.edu">Technical Direction
<option value="playpr@pitt.edu">Season Schedule
<option value="playpr@pitt.edu">Others
<option value="shrutimp@yahoo.com">Test
</select>
</TD>
</TR>
<br><br>
<TR ALIGN=LEFT VALIGN=TOP>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">
Subject:* </font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="subject" SIZE=40 MAXLENGTH=60>
</font></TD></TR> <br><br>
<TR ALIGN=LEFT VALIGN=TOP>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">
Name:* </font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="yourname" SIZE=40 MAXLENGTH=60>
</font></TD></TR> <br><br>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2"> Address1:* </font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1">
<font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="address1" SIZE=40 MAXLENGTH=120 >
</font><P></TD></TR>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1">
<font face="Arial, Helvetica, sans-serif" size="2">Address2: </font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="address2" SIZE=40 MAXLENGTH=120 >
</font>
<P></TD></TR>
<TR>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">City:* </font></TD> <TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="city" SIZE=30 MAXLENGTH=60 >
</font><P></TD></TR>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">State:* </font></TD> <TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2"> <INPUT NAME="state" SIZE=5 MAXLENGTH=5></font>
<P></TD></TR>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">Zip Code:*</font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="zip" SIZE=15 MAXLENGTH=15></font><P></TD></TR>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">Phone: </font></TD> <TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="phone" SIZE=30 MAXLENGTH=45></font><P></TD></TR>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">Email:* </font></TD> <TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<INPUT NAME="email" SIZE=30 MAXLENGTH=60></font><P></TD><TR>
<TR><TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"><font face="Arial, Helvetica, sans-serif" size="2">Comments: </font></TD>
<TD ALIGN=LEFT VALIGN=TOP COLSPAN="1"> <font face="Arial, Helvetica, sans-serif" size="2">
<TEXTAREA NAME="comments" COLS=40 ROWS=8 wrap=virtual></TEXTAREA>
</font></TD></TR></TABLE><br><br>
<font face="Arial, Helvetica, sans-serif" size="2">
<INPUT type="hidden" name="hidden1">
<INPUT TYPE="button" VALUE="Submit" onClick="email( this.form.hidden1.value );">
<INPUT TYPE="reset" VALUE="Clear">
<BR>
</FORM><div align="center">

<script language = "JavaScript">
<!--


function email( MailTo )

{
window.location = "mailto:"+MailTo;
}


function change( )

{
document.form.hidden1.value = document.form.name.value;
}


-->
</script>

</div></body></html>

Could you please help where the problem is?
Thank you
 
Actually, this is where the problem seems to be:
onClick = "email(this.form.hidden1.value)
 
I personally do not like receiving form submissions via email. If you have webspace (which you probably do to host your site) and MS Access .. maybe it would be more feasible to receive form submissions and have the field information inserted into a table on the database.

If thats not the case I'll look at your code.
 
I dont want to use a database here. The form is just for the purpose of sending the form fields to the respective email addresses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top