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

Drop Down and Email

Status
Not open for further replies.

MnM

Programmer
Nov 1, 2000
47
0
0
US
I know I've seen this somewhere and I can't find it and its driving me crazy! I'm not sure if this is the right forum to be posting this in but I thought I've give it a try.

What I have is a form and on that form I have a drop down with out store locations. When they submit that form I want it to e-mail the form to the location they selected. How would that be done?

Thanks in advance!
 
Do all choices in the drop-down go to the same email address??
If yes then use this:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;mailto:emailaddyhere@someone.com&quot;>
<p>
<select name=&quot;select&quot; size=&quot;1&quot;>
<option value=&quot;select&quot;>Select one</option>
<option value=&quot;one&quot;>one</option>
<option value=&quot;two&quot;>two</option>
<option value=&quot;three&quot;>three</option>
<option value=&quot;four&quot;>four</option>
</select>
</p>
<p>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</p>
</form>
</body>
</html>
I have not failed; I merely found 100,000 different ways of not succeding...
 
No that's what I'm having trouble figuring out. All the e-mails would go to a differnt person

if you select Store 1 it needs to go to Store1@here.com
Store 2 needs to go to Store2@here.com
ect. ect.
 
Code:
<form method=&quot;post&quot;>
<select onchange=&quot;this.form.action='mailto:' + this.options[this.options.selectedIndex].value; this.form.submit();&quot;>
<option value=&quot;store1@here.com&quot;>Store 1
<option value=&quot;store2@here.com&quot;>Store 2
<option value=&quot;store3@here.com&quot;>Store 3
</select>
</form>
It's not a lie if YOU believe it ;-)
 
Okay I understand what drgenius is doing but I don't think I can use that. I'm using a formmail.pl for my form and it has a recipient field which you put who the form goes to. I put the code below, in the recipient I have here@there.com but I don't want the form to go to that person, as I stated above I want it to go to who they select from the &quot;closest_location&quot; drop down. I've added the store e-mail into the value of the option tag but not sure what to do with it. I tried using different variations of what drgenius code said but just couldn't get it to work. What I've tried to do is tell the value of recipient to look at the value of closest_location but can't get it to work. Am I on the right track by doing that? What I have for my code right now is below:

<FORM METHOD=&quot;POST&quot; ACTION=&quot;<input type=&quot;hidden&quot; name=&quot;recipient&quot; value=&quot;here@there.com&quot;>
<input type=&quot;hidden&quot; name=&quot;subject&quot; value=&quot;Comment or Question&quot;>
<input type=&quot;hidden&quot; name=&quot;return_link_url&quot; value=&quot;<input type=&quot;hidden&quot; name=&quot;return_link_title&quot; value=&quot;Back to Main Page&quot;>
<input type=&quot;hidden&quot; name=&quot;required&quot; value=&quot;Name, email, closest_location, Question&quot;>
<input type=hidden name=&quot;redirect&quot; value=&quot;<tr>
<td align=center colspan=3><font face=arial, helvetica size=2><font color=#db2336>*</font> Indicates required information</font></td>
<tr>
<td align=right width=40%><font color=#db2336>*</font><font face=arial, helvetica size=2>Full Name: </font></td>
<td align=left><font face=arial, helvetica size=2><input type=&quot;text&quot; name=&quot;Name&quot; size=&quot;20&quot;></font></td>
</tr>
<tr>
<td align=right><font face=arial, helvetica size=2><font color=#db2336>*</font>E-Mail: </font></td>
<td align=left><font face=arial, helvetica size=2><input type=&quot;text&quot; name=&quot;email&quot; size=&quot;20&quot;></font></td>
</tr>
<tr>
<td align=right><font face=arial, helvetica size=2><font color=#db2336>*</font>Store Near You: </font></td>
<td align=left><font face=arial, helvetica size=2><SELECT name=&quot;closest_location&quot;>
<option></option>
<option value=&quot;store1@store.com&quot;>Store1</option>
<option value=&quot;store2@store.com&quot;>Store2</option>
<option value=&quot;store3@store.com&quot;>Store3</option>
</select></font></td>
</tr>
<tr>
<td align=center colspan=2><font face=arial, helvetica size=2><font color=#db2336>*</font>Comments / Questions: </font>
<br><font face=arial, helvetica size=2><textarea name=&quot;Question&quot; rows=&quot;5&quot; cols=&quot;35&quot;></textarea></font><p></td>
</tr>
<td align=center colspan=2><font face=arial, helvetica size=2><input type=&quot;SUBMIT&quot; value=&quot;Submit Form&quot;>
<input type=&quot;RESET&quot; value=&quot;Reset Form&quot;><p></td>
</tr>
</form>
 
Put something like this in your form-tag (untested):

Code:
onsubmit=&quot;this.action='mailto:' + this.closest_location.options[this.closest_location.options.selectedIndex].value&quot;;

PS: I noticed some tags are missing in your code (e.g. </td>, <table>, etc) so you might wanna check that. It's not a lie if YOU believe it ;-)
 
yeah i just grabbed a little bit of the code so some of the html tags are missing. i just wanted people to see the form code mostly. i already have a function i'm calling from the onsubmit (i left it out above) if I was to add the mailto code to a function how would i do it? I've tried a couple of ways but it wouldn't work. if i can get your code (drgenius) to work it will be nice, but I'd still like a way i can pass the drop down value you the value of recipient.
 
wullie!!!!!!! How dense am I! That was soooooo easy. I knew it had to be something simple, and sure enough it was, I feel like a moron because I even asked the question! Thanks to all who answered.
 
Hi mate,

It is the easiest of questions that normally take the longest to work out.. LOL

Any of your hidden fields can be included in a dropdown..

Also, subject etc. can be used as a textarea so that the user fills out the subject themselves.

If you have a large form for different uses then you can also use the required fields in a dropdown and depending on what service the user selects then the required fields also change to match.

Hope this helps Wullie

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top