Mark said:
I can create a form and send it to one e-mail address my question is
how can I send it to more than one e-mail address?
Here is a page which I wrote. It has a form which asks for persons who want
to join a tour (but that is incidental to your needs).
It asks for 4 EMail addresses, checks them and writes them to the To:
address of the Email. separated by ';'. I think either ';' or ',' will
work.
The rest of the fields are written to the body - one is reformatted.
You can alter the form as you like, but leave the last two input boxes -
Send and Clear. These are deleted from the Email.
For example, you may want to add names as well as Email addresses
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<!-- formtest.html -->
<head>
<title>Form Test</title>
<meta name="Author" content="Trevor Lawrence"/>
<meta http-equiv="Content-Language" content="en-au"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- Internal JS -->
<script type="text/javascript">
function checkEmailAddress(field)
{
// the following expression in () after 'match' must be all on one line...
if
(field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi))
return true
else
{ alert('Please enter a valid e-mail address.')
field.focus()
field.select()
return false }
}
// --------------------
function testform()
{
with (document.form1)
{
for (var i = 1; i <= 4 ; i++)
if (!checkEmailAddress(elements['Email' + i]))
return
var yesreply = yes.checked
var noreply = no.checked
if (yesreply == noreply)
{ alert ('Reply must be Yes or No')
return }
else
Joining.value = yesreply ? 'Yes' : 'No'
}
}
// --------------------
function sendform()
{
var recpt = ''
for (var i = 1; i <= 4 ; i++)
{
recpt += document.form1.elements['Email' + i].value
if (i < 4 )
recpt += ';'
}
with (document.form1)
{
var body = ''
var i = elements.length , j = 0
while (i-- > 2) // drop last two elements
{
var tname = elements[j].id
var text = (elements[j].checked) ? 'Yes' : elements[j].value
// alert(tname)
if (text != 'on' && tname != 'yes' && tname != 'no' &&
tname.substr(0,5) != 'Email' )
{
body += tname + ": "
if (tname == "Comment")
body += '%0d%0a' // line break before comment text
body += text + '%0d%0a' // line break after each line
}
j += 1
} // end while
}
window.location = "mailto:" + recpt
+ "?subject=Response%20from%20Form1"
+ "&body=" + body
}
// --------------------
</script>
</head>
<!-- ================================================ -->
<body onload="">
<noscript>
This site requires Javascript enabled<br />
</noscript>
<div id="maindiv" align="center">
<div style="border:1px solid #999999; width:60%;
background-color:#F2F4FA;">
<form name="form1" action="">
<div style="background-color:#DBE0F5; padding:3px; font:75% arial;">
<b>Title</b>
</div>
<div style="padding:10px; font:75% Arial; text-align:left;">
<p>
Hi all,<br />
Do you want to join my trip ?
</p>
<p>
Email1:<br/>
<input type="text" id="Email1" value="Insert e-mail address" size="40"
onfocus="if (this.value=='Insert e-mail
address'){this.value='';};return false;"
onblur="if (this.value==''){this.value='Insert e-mail
address';return false;}"/><br/>
Email2:<br/>
<input type="text" id="Email2" value="Insert e-mail address" size="40"
onfocus="if (this.value=='Insert e-mail
address'){this.value='';};return false;"
onblur="if (this.value==''){this.value='Insert e-mail
address';return false;}"/><br/>
Email3:<br/>
<input type="text" id="Email3" value="Insert e-mail address" size="40"
onfocus="if (this.value=='Insert e-mail
address'){this.value='';};return false;"
onblur="if (this.value==''){this.value='Insert e-mail
address';return false;}"/><br/>
Email4:<br/>
<input type="text" id="Email4" value="Insert e-mail address" size="40"
onfocus="if (this.value=='Insert e-mail
address'){this.value='';};return false;"
onblur="if (this.value==''){this.value='Insert e-mail
address';return false;}"/><br/>
Do you want to join? <br/>
<input type="checkbox" id="yes" />Yes <br/>
<input type="checkbox" id="no" />No <br/>
<input type="hidden" id="Joining" size="3" />
</p>
Enter Comment:<br/>
<textarea id="Comment" rows="10" cols="100"
style="font:100% Arial;">Enter your comment in
here</textarea><br />
</div>
<div align="center" style="background-color:#DBE0F5; padding:3px;
font:12px arial;">
<input type="button" id="submit" value=" Send "
onmouseover="testform()" onclick="sendform()" />
<input type="reset" id="reset" value=" Clear "/>
</div>
</form>
</div>
</div> <!-- end id="maindiv" -->
</body>
</html>