Submitting to multiple email addresses

  • iplaydirty
  • Newbie
  • Newbie
  • iplaydirty
  • Posts: 6

Post 3+ Months Ago

Hi,

I'm new to the forum, but not new to html. I'm sure I'll be able to help quite a few people as well.

But first, I have a forms question. I know most of this will probably come down to what formmailer I'm using, and unfortunaltely, I don't know. I'm working on a corporate intranet site and have to adhere to theirs.

With that said, I have a pulldown menu with 18 states in it and some other various text fields etc. I need the form to email one of five different addresses based on the state the user selects. I'm really lacking in scripting knowledge and I know it's going to come down to that.

I do know the server I'm using does not support CGI or PHP.

Any help would be greatly appreciated.

Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

How are you telling the form mailer where to send the submitted information? Is there a hidden field that you can set with the email address?

With client-side javascript it is possible to detect which one of the drop-down selections is chosen and then decide which email address to use as long as the formmail script allows you to set something like a hidden field with the email address.
  • iplaydirty
  • Newbie
  • Newbie
  • iplaydirty
  • Posts: 6

Post 3+ Months Ago

<table BORDER="1" CELLSPACING="1" CELLPADDING="2"bordercolordark="#666666" bordercolorlight="#CCCCCC" class="bodyText">
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" BGCOLOR="#C0C0C0" class="bodyText">Field Name</td>
<td WIDTH="56" BGCOLOR="#C0C0C0" class="bodyText">Type</td>
<td WIDTH="335" BGCOLOR="#C0C0C0" class="bodyText">What it's for</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" BGCOLOR="#FFFFCC" class="bodyText">Message Fields</td>
<td WIDTH="56" BGCOLOR="#FFFFCC" class="bodyText">&</td>
<td WIDTH="335" BGCOLOR="#FFFFCC" class="bodyText">&</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">mailto</td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">E-mail address(es) to send mail to. &
If this is not specified, email will not be sent.& </td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">mailcc</td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">E-mail address(es) to copy</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">mailsubj</td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">The subject of the e-mail message</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">emailfrom</td>
<td WIDTH="56" class="bodyText">text</td>
<td WIDTH="335" class="bodyText">The e-mail address of the person filling
out the form</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">boundary</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">Any field name with &boundary&
in it will translate to a line separator in the e-mail message</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">message</td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">The value of any field name with
&message& in it will translate to text in the e-mail message without the
fieldname being included.</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">inputfile</td>
<td WIDTH="56" class="bodyText">file</td>
<td WIDTH="335" class="bodyText">This is the name of the field used for
attaching a document. Only one document can be attached.</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">Referring_URL</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">When this field is included with a value
of &Yes& the e-mail message will include the URL of the page which submitted the
message.</td>
</tr>
<tr>
<td WIDTH="98" class="bodyText">doublespace</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">Values of NO, No, or no cause the fields
in the message to be sent with no blank line in-between.& Any other value, or not
including the field, will cause a blank line to appear in the message between each field.</td>
</tr>
<tr>
<td WIDTH="98" class="bodyText">showblanks</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">By default, if a user does not fill out a
field on your form, it will be printed in the email with a blank value.& Values of
no, No, or NO in this hidden field will cause blank values to be removed from the email. </td>
</tr>
<tr>
<td WIDTH="98" class="bodyText">hiddenfields</td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">Any form field names specified in this
field will not be printed in the email.& Separate field names by a comma.</td>
</tr>
<tr>
<td WIDTH="98" class="bodyText"><a name="order">order</a></td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">Order in which fields should appear in
email.& Field names should be separated by a comma.& If this field is not
specified, fields will be printed in alphabetical order. See <a href="#orderscript">below</a> for how to automatically populate this field in your form. </td>
</tr>
<tr>
<td WIDTH="98" class="bodyText">sendinvalidemail</td>
<td WIDTH="56" class="bodyText">Any type</td>
<td WIDTH="335" class="bodyText">The default behavior is to report an error to the user if an invalid email address is found in the form. A value of YES, Yes, or yes in this
field will allow the form to &send& email to invalid email addresses.
& Valid email address will receive the email, while invalids will be &thrown
away&.</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" BGCOLOR="#FFFFCC" class="bodyText">Response Fields</td>
<td WIDTH="56" BGCOLOR="#FFFFCC" class="bodyText">&</td>
<td WIDTH="335" BGCOLOR="#FFFFCC" class="bodyText">&</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">showtitle</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">Title displayed in browser window after
form submission</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">bgcolor</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">Background color of page displayed after
form submission</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">textcolor</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">Text color of page displayed after form
submission</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">showmsg</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">Message on page displayed after form
submission</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">showurl</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">URL that will be used as a link on the
response page after the form is submitted</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">showurlname</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">The name that will be displayed on the
response page for the URL defined by `showurl'</td>
</tr>
<tr VALIGN="top" ALIGN="left">
<td WIDTH="98" class="bodyText">redirecturl</td>
<td WIDTH="56" class="bodyText">hidden</td>
<td WIDTH="335" class="bodyText">URL to redirect to immediately after form
submission</td>
</tr>
</table>


Thats what I've been given for hidden fields.

Also, sorry for the 2 pages of blank space above this table.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Ok, it looks like "mailto" is the one that sets the address where the form data will be sent.

If you tell me the grouping I can try to make a script and you can fill in the state names and email addresses. By grouping I mean how many states will go with each address. I don't need to know the actual state names or email address.

For example,

1st email = 3 states
2nd email = 4 states
3rd email = 4 states
4th email = 4 states
5th email = 3 states
  • iplaydirty
  • Newbie
  • Newbie
  • iplaydirty
  • Posts: 6

Post 3+ Months Ago

1st email = 1 state
2nd email = 4 states
3rd email = 4 states
4th email = 8 states
5th email = 1 state

I really appreciate this, thank you.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Ok, here's something to try:

Code: [ Select ]
<html>
<head>
<title>Untitled</title>
<script language="javascript">
<!--
function setStateField()
{
    var stateField = document.theForm.state;
    var selected = document.theForm.mailto.selectedIndex;
    stateField.value = document.theForm.mailto[selected].innerHTML;
}
// -->
</script>
</head>
<body>
<form name="theForm" action="" method="">

<select name="mailto" onchange="setStateField()">

<option value="email1@some.com">state1</option>

<option value="email2@some.com">state2</option>
<option value="email2@some.com">state3</option>
<option value="email2@some.com">state4</option>
<option value="email2@some.com">state5</option>

<option value="email3@some.com">state6</option>
<option value="email3@some.com">state7</option>
<option value="email3@some.com">state8</option>
<option value="email3@some.com">state9</option>

<option value="email4@some.com">state10</option>
<option value="email4@some.com">state11</option>
<option value="email4@some.com">state12</option>
<option value="email4@some.com">state13</option>
<option value="email4@some.com">state14</option>
<option value="email4@some.com">state15</option>
<option value="email4@some.com">state16</option>
<option value="email4@some.com">state17</option>

<option value="email5@some.com">state18</option>
</select>
<input type="hidden" name="state" value="state1">
<input type="submit">
</form>

</body>
</html>
  1. <html>
  2. <head>
  3. <title>Untitled</title>
  4. <script language="javascript">
  5. <!--
  6. function setStateField()
  7. {
  8.     var stateField = document.theForm.state;
  9.     var selected = document.theForm.mailto.selectedIndex;
  10.     stateField.value = document.theForm.mailto[selected].innerHTML;
  11. }
  12. // -->
  13. </script>
  14. </head>
  15. <body>
  16. <form name="theForm" action="" method="">
  17. <select name="mailto" onchange="setStateField()">
  18. <option value="email1@some.com">state1</option>
  19. <option value="email2@some.com">state2</option>
  20. <option value="email2@some.com">state3</option>
  21. <option value="email2@some.com">state4</option>
  22. <option value="email2@some.com">state5</option>
  23. <option value="email3@some.com">state6</option>
  24. <option value="email3@some.com">state7</option>
  25. <option value="email3@some.com">state8</option>
  26. <option value="email3@some.com">state9</option>
  27. <option value="email4@some.com">state10</option>
  28. <option value="email4@some.com">state11</option>
  29. <option value="email4@some.com">state12</option>
  30. <option value="email4@some.com">state13</option>
  31. <option value="email4@some.com">state14</option>
  32. <option value="email4@some.com">state15</option>
  33. <option value="email4@some.com">state16</option>
  34. <option value="email4@some.com">state17</option>
  35. <option value="email5@some.com">state18</option>
  36. </select>
  37. <input type="hidden" name="state" value="state1">
  38. <input type="submit">
  39. </form>
  40. </body>
  41. </html>


For this to work the form tag must have name="theForm" and the name of the first state must be the value of the hidden field "state". You can put the states in the drop-down menu in any order that you want provided that the first state name is the same as the hidden field.

Obviously, this will work correctly only if the user has javascript enabled. If the user has disabled javascript then the form data will still go to the correct address, but the value of the first state in the list will be sent regardless of which was selected, because all the script does is grab the text between the <option></option> and assign it to the hidden field.
  • iplaydirty
  • Newbie
  • Newbie
  • iplaydirty
  • Posts: 6

Post 3+ Months Ago

Wow.

Thanks a ton for this.

I do have a question though. How much of this is safe to change. The problem is, the email addresses that this form is going to is run by a department that's, well, let's say "lacking IQ." I need the form output to read just like any other. Basically, the state output can ONLY say State: <name>.

Will this form give the output as though the state had nothing to do with how it got there?

Thanks again.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

You can change pretty much anything you want, so long as the first state name is the default value for the hidden field.

If you want to change the name of the form (or if the form you're using already has a name) just make a corresponding change in the script. For example, say your form is already named myForm instead of theForm. Then you would change "theForm" in the script to "myForm" in the three places that it appears in the script.

If you want the hidden field to be capitalized to "State" instead of "state" change it's name and then change:

var stateField = document.theForm.state;

to

var stateField = document.theForm.State;

The script references these two parts of the form, i.e. it's name and the name of the hidden field for state, so if you change these change them in the script too.

The hidden field should be passed just like any other field in your form. You could test it by using your own email addresses (<option
value="myaddress@blah.com">TEST</option>) and then loading the form in your browser, selecting the one you set and submitting it. Then see what shows up in your inbox.
  • iplaydirty
  • Newbie
  • Newbie
  • iplaydirty
  • Posts: 6

Post 3+ Months Ago

well, it DEFINITELY worked which is a HUGE step in getting this done.

I added 2 additional fields "Test1" and "Test2" each with different email addresses. When I view the response form, I need the state the user selected to display. I did what you said and named it the first state as default, but no matter what option is selected, the form output always displays only the first state.

How can I fix this?
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Did you remember to put name="theForm" inside the form tag?

If you changed the name of the hidden state field did you remember to change the corresponding part of the script?

If yes, then you'll have to show me the code for your form as you have it set up now and I'll try to see if I can troubleshoot it.
  • iplaydirty
  • Newbie
  • Newbie
  • iplaydirty
  • Posts: 6

Post 3+ Months Ago

lol

of the 2 things I was supposed to do, of course I forgot one of them. Yes, the problem was the form name. I updated the js but not the actual form.

Well RichB, you have solved a problem that no one else has been able to answer for me. I am much in your debt.

Thank you so much.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

You're most welcome. I'm glad it worked out for you. :D
  • danika
  • Born
  • Born
  • danika
  • Posts: 1

Post 3+ Months Ago

Hi there,

Forgive me for being slow on this :oops: , but could you give an example of specifying a distinct email address for different checkbox items while still sending every form submission to an overall address?

i.e.:

form sent to email@domain.com - always
as well as
checkbox item1 mailto
checkbox item2 mailto
checkbox item3 mailto
a.s.o.


Thanks so much in advance!

Danika


RichB wrote:
Ok, here's something to try:

Code: [ Select ]
<html>
<head>
<title>Untitled</title>
<script language="javascript">
<!--
function setStateField()
{
    var stateField = document.theForm.state;
    var selected = document.theForm.mailto.selectedIndex;
    stateField.value = document.theForm.mailto[selected].innerHTML;
}
// -->
</script>
</head>
<body>
<form name="theForm" action="" method="">

<select name="mailto" onchange="setStateField()">

<option value="email1@some.com">state1</option>

<option value="email2@some.com">state2</option>
<option value="email2@some.com">state3</option>
<option value="email2@some.com">state4</option>
<option value="email2@some.com">state5</option>

<option value="email3@some.com">state6</option>
<option value="email3@some.com">state7</option>
<option value="email3@some.com">state8</option>
<option value="email3@some.com">state9</option>

<option value="email4@some.com">state10</option>
<option value="email4@some.com">state11</option>
<option value="email4@some.com">state12</option>
<option value="email4@some.com">state13</option>
<option value="email4@some.com">state14</option>
<option value="email4@some.com">state15</option>
<option value="email4@some.com">state16</option>
<option value="email4@some.com">state17</option>

<option value="email5@some.com">state18</option>
</select>
<input type="hidden" name="state" value="state1">
<input type="submit">
</form>

</body>
</html>
  1. <html>
  2. <head>
  3. <title>Untitled</title>
  4. <script language="javascript">
  5. <!--
  6. function setStateField()
  7. {
  8.     var stateField = document.theForm.state;
  9.     var selected = document.theForm.mailto.selectedIndex;
  10.     stateField.value = document.theForm.mailto[selected].innerHTML;
  11. }
  12. // -->
  13. </script>
  14. </head>
  15. <body>
  16. <form name="theForm" action="" method="">
  17. <select name="mailto" onchange="setStateField()">
  18. <option value="email1@some.com">state1</option>
  19. <option value="email2@some.com">state2</option>
  20. <option value="email2@some.com">state3</option>
  21. <option value="email2@some.com">state4</option>
  22. <option value="email2@some.com">state5</option>
  23. <option value="email3@some.com">state6</option>
  24. <option value="email3@some.com">state7</option>
  25. <option value="email3@some.com">state8</option>
  26. <option value="email3@some.com">state9</option>
  27. <option value="email4@some.com">state10</option>
  28. <option value="email4@some.com">state11</option>
  29. <option value="email4@some.com">state12</option>
  30. <option value="email4@some.com">state13</option>
  31. <option value="email4@some.com">state14</option>
  32. <option value="email4@some.com">state15</option>
  33. <option value="email4@some.com">state16</option>
  34. <option value="email4@some.com">state17</option>
  35. <option value="email5@some.com">state18</option>
  36. </select>
  37. <input type="hidden" name="state" value="state1">
  38. <input type="submit">
  39. </form>
  40. </body>
  41. </html>


For this to work the form tag must have name="theForm" and the name of the first state must be the value of the hidden field "state". You can put the states in the drop-down menu in any order that you want provided that the first state name is the same as the hidden field.

Obviously, this will work correctly only if the user has javascript enabled. If the user has disabled javascript then the form data will still go to the correct address, but the value of the first state in the list will be sent regardless of which was selected, because all the script does is grab the text between the <option></option> and assign it to the hidden field.

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 139 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.