Multiple email addresses in one form

  • Lawyer
  • Born
  • Born
  • Lawyer
  • Posts: 4

Post 3+ Months Ago

Hi all,

new here and really need your help. I have created a form with a drop down box that has two options. I would like the form to go to two different email addresses based on which one of the two options was clicked...... Does that make sense........ :oops:
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

http://javascript.internet.com/generato ... -menu.html

You could give this a shot. ;)

HTH!
  • Lawyer
  • Born
  • Born
  • Lawyer
  • Posts: 4

Post 3+ Months Ago

Digital Media,

ta for the link, gave it a bash and I still only seem to manage to get the form sent to one email address, do you have any idea what you might be doing wrong? :oops:
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

oh. i see. I think I read your original question incorrectly. What scripting language are you using to handle the form?

All you really need to do is collect the value they set with the drop down, and use some logic like...
Code: [ Select ]
if (dropdown===1) {

   mailto = "thisbox@thisdomain.com";

} else if (dropdown===2) {

   mailto = "thisotherbox@thisdomain.com";

}
  1. if (dropdown===1) {
  2.    mailto = "thisbox@thisdomain.com";
  3. } else if (dropdown===2) {
  4.    mailto = "thisotherbox@thisdomain.com";
  5. }


So this is an ActionScript like language, but you get the drift, yes?

If you could post the script that you're using to handle the form, that would probably make things a bit easier. Regardless of the language someone here will be able to help you.

Also, this thread will likely need to get moved to the scripting category.
  • Lawyer
  • Born
  • Born
  • Lawyer
  • Posts: 4

Post 3+ Months Ago

Digital, I have to confess I am a total novice at this (think that is obvious).
Here is the code I am using to generate the form.
Code: [ Select ]
<form method="post" action="mailto:am@best.com" enctype="text/plain">
<font>me</font>
<select name="me" size="1">
<option>A
<option>B
</select>
</form>
  1. <form method="post" action="mailto:am@best.com" enctype="text/plain">
  2. <font>me</font>
  3. <select name="me" size="1">
  4. <option>A
  5. <option>B
  6. </select>
  7. </form>

It is when option A or B is chosen that I would like the form to go to different email addresses.

Thanks for your help with this!! :iconthumbleft:
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6807
  • Loc: Martinsburg, WV

Post 3+ Months Ago

From what I can see in the code is because of
Code: [ Select ]
action="mailto:am@best.com"
no matter what they choose it will be sent to the e-mail address in the action. I am having a similar problem with a dropdown. I want the drop down to take you to different pages, very similar to the jump to box here on the forum and I can't get it to work.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

You can use javascript to set the action property of the form as long as the user has javascript enabled.

Code: [ Select ]
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function setEmail(){
theForm = document.mailForm;
theForm.action = "mailto:" + theForm.me.options[theForm.me.selectedIndex].value;
}
// -->
</script>
</head>
<body>
<form name="mailForm" method="post" action="mailto:email1@one.com" enctype="text/plain">
<select name="me" size="1" onchange="setEmail()">
<option value="email1@one.com">A</option>
<option value="email2@two.com">B</option>
</select>
<input type="submit">
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Untitled</title>
  4. <script type="text/javascript">
  5. <!--
  6. function setEmail(){
  7. theForm = document.mailForm;
  8. theForm.action = "mailto:" + theForm.me.options[theForm.me.selectedIndex].value;
  9. }
  10. // -->
  11. </script>
  12. </head>
  13. <body>
  14. <form name="mailForm" method="post" action="mailto:email1@one.com" enctype="text/plain">
  15. <select name="me" size="1" onchange="setEmail()">
  16. <option value="email1@one.com">A</option>
  17. <option value="email2@two.com">B</option>
  18. </select>
  19. <input type="submit">
  20. </form>
  21. </body>
  22. </html>
  • Buddha
  • Newbie
  • Newbie
  • User avatar
  • Posts: 8

Post 3+ Months Ago

Do you have any suggestions on how to assign the mailto address from the select line choice :?: I tried use the selection to assign the email address, but the action line needs a value in order to post.

Many thanks in advance for this.
  • MasterZ
  • Expert
  • Expert
  • User avatar
  • Posts: 699
  • Loc: Colorado Springs

Post 3+ Months Ago

how I do it, (using php)

I have several email addresses listed in a variable.

In the form I have a drop down menu list all the different selections, then a page reads that list and emails who it needs to.

so

PHP Code: [ Select ]
 
echo "
 
<form name='mailForm' method='post' action='mailsend.php' enctype='text/plain'>
 
<select name='me' size='1'>
 
<option value='webmaster'>Web Master</option>
 
<option value='admin'>Admin</option>
 
</select>
 
<input type='submit'>
 
</form>
 
</body>
 
</html>
 
";
 
 
  1.  
  2. echo "
  3.  
  4. <form name='mailForm' method='post' action='mailsend.php' enctype='text/plain'>
  5.  
  6. <select name='me' size='1'>
  7.  
  8. <option value='webmaster'>Web Master</option>
  9.  
  10. <option value='admin'>Admin</option>
  11.  
  12. </select>
  13.  
  14. <input type='submit'>
  15.  
  16. </form>
  17.  
  18. </body>
  19.  
  20. </html>
  21.  
  22. ";
  23.  
  24.  


then on page mailsend.php
PHP Code: [ Select ]
 
$mailto = $_POST['me'];
 
 
 
if($mailto == 'webmaster')
 
{
 
  $email = "one@one.com";
 
}elseif($mailto == 'admin'){
 
  $email = "two@two.com";
 
};
 
 
  1.  
  2. $mailto = $_POST['me'];
  3.  
  4.  
  5.  
  6. if($mailto == 'webmaster')
  7.  
  8. {
  9.  
  10.   $email = "one@one.com";
  11.  
  12. }elseif($mailto == 'admin'){
  13.  
  14.   $email = "two@two.com";
  15.  
  16. };
  17.  
  18.  


You get the idea.....

It's really easy, and you can turn it into something really powerful.
  • Buddha
  • Newbie
  • Newbie
  • User avatar
  • Posts: 8

Post 3+ Months Ago

That is very eloquent. Thanks for the help. I was thinking that it is possible with PHP, but I have only begun learning that. Do you have any suggestions on how to do that with javascript? At present the site that I work for does not support ASP or PHP. I think it is just a simple matter of a configuration problem. Thanks again.

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 43 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.