KML said:
Is there a way to have the actual form with the results send via
email? I've FrontPage 2003 and I can send the form results to an
email. I want to go an extra step by sending the whole form with the
results. FP's Form Properties has the Send to Other option using
Custom ISAPI, NSAPI, CGI or ASP script, which I read can do this.
Does anyone has example of these scripts and some instructions or
could direct me to websites that have information to do this? Thanks!
Here is a form which submits an email to several addresses. I wrote it in
reply to another query so modify it as you want.
Unfortunately it won't format the email to look like the form but it does
retain all the fields and their values.
The important bits to keep are
<form name="form1" action="">
and
<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>
(This <div> needs to be last because the script deletes it from the email,
but the style can be what you like.)
Also keep the functions
testform()
sendform()
although you can modify these to do what you want
<!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(/(^(\S+@)\S+(((\.ac)|(\.aero)|(\.arpa)|(\.biz)|(\.co)|(\.com)|(\.coop)|(\.edu)|(\.firm)|(\.gov)|(\.info)|(\.int)|(\.jobs)|(\.mil)|(\.museum)|(\.name)|(\.nom)|(\.net)|(\.org)|(\.pro)|(\.store)|(\.travel)|(\.web))(\.\S{2})?)$)/i))
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
if (text != 'on' && tname != 'yes' && tname != 'no' &&
!tname.match(/(^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 />
</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>
</body>
</html>