HTML/Javascript: send form to multiple addresses?

Is this possible without server-side script? I cannot find any examples. Everything I find comes back down to the fact that every form only has one place to put the sendto address.

I believe you can’t.

I’m not aware of this either. IIRC, this method also relies on the user’s default email client being able to send the form when called by the browser, and not everyone’s browser/mail client is configured correctly.

Of course this may not be your reason, but assuming that you don’t want to use server-side script because you don’t know how to, I recommend a very simple implementation of a server-side Perl script with comprehensive documentation - the famous FormMail.pl is available at Matt’s Script Archive.

      • I don’t use server-side script because I can’t. Server scripts are not an option. Oh well.
        ~

How about asking the postmaster at the recipient address’s mailserver to create an alias that includes the multiple addresses to which you want the form to go?

IIRC, the forms on Websites uses the http protocol, while e-mail uses SMTP.

HTML forms can’t submit to more than one address. However, they can be submitted more than once.

The <form> tag can take a TARGET attribute that controls which frame/iframe/window the data is submitted into. If this target is something other than the current window then you can keep the form data and client-side code running.

For example, if you have a form similar to the one below:



<form method="get" action="http://test" name="myForm" target="_NEW">
	<input type="hidden" name="sendto" value="someone@somewhere.com"/>
	<input type="submit" value="Test"/>
</form>


Then each click of the submit button will open a new window while the original remains unchanged.

You could have a piece of javascript that submits the form, changes the sendto data (or any other data), then submits it again.



<script language="JavaScript">
	document.myForm.submit();
	document.myForm.sendto.value="nextone@somewhere.com";
	document.myForm.submit();
</script>


By adjusting the TARGET attribute of the form you can control where the submissions appear; either in new windows with “_NEW” or in a named frame. To prevent windows popping up include either a small invisible frame on your page or an iframe in a hidden div.

I haven’t tested this in Netscape, but I don’t see any real reason why it wouldn’t work.

Alternatively, I’ve found that separating email addresses with commas often works. Depends on the mailer script being used.

I hope this helps.

It sounds like you’re talking about using a mailto form action instead of submitting to a server-side script. If that is the case, you can specify multiple email recipients by simply including them in a comma-delimited list in the mailto action. Almost anything that processes email will handle a comma-delimited list of addresses in place of a single address.


<form action="mailto:me@mycomp.com,you@yourcomp.com">

As jjimm points out, this method of form processing won’t work for many clients because users have disabled the mail integration in the browser as a security measure. I’m willing to accept your “can’t use them” as final, but if you’re using a commercial host that allows you to post HTML, it’s likely they provide at least a generic server-side form processor. If you’re using a server that doesn’t, well, that’s that.