allyson
11-07-2002, 05:38 AM
Hi
Take a look at http://homepages.ihug.co.nz/~usateden/panacea/organisation/enrolment2.htm . The javascript code makes sure that the form is filled in accurately, and when the user clicks 'Send' the alert box comes up, saying that the information has been sent, but the form does not go to the stated email address. I think that I haven't set up the action properly. How could I modify the script, so that action is set up properly? Please help. Thank-you.
<form name="TheForm">
<p><input type="text" name="nm" size="30">Name <br>
<input type="text" name="age" size="5">Age <br>
<input type="text" name="add" size="40">Address <br>
<input type="text" name="city" size="40">City<br>
<br>
<input type="text" name="disability" size="40">Disability<br>
<br>
<input type="text" name="em" size="33"> E-mail address <br>
<input type="text" name="emx" size="33"> Re-enter to confirm </p>
<div align="center"><center><p> </p>
</center></div><div align="center"><center><p><input type="button" value="Submit"
name="SB" onClick="sendOff();"><input type="reset" name="B2" value="Reset"> <script
language="JavaScript1.2">
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
var good;
function checkEmailAddress(field) {
// Note: The next expression must be all on one line...
// allow no spaces, linefeeds, or carriage returns!
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){
good = true
} else {
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
}
function sendOff(){
nmcheck = document.TheForm.nm.value
adcheck = document.TheForm.add.value
agecheck=document.TheForm.age.value
discheck=document.TheForm.disability.value
if (nmcheck.length <1) {
alert('Please enter your name.')
return
}
if (adcheck.length<1) {
alert('Please enter your address.')
return
}
if (agecheck.length<2) {
alert('Please enter your age.')
return
}
good = false
checkEmailAddress(document.TheForm.em)
if ((document.TheForm.em.value ==
document.TheForm.emx.value)&&(good)){
// This is where you put your action
// if name and email addresses are good.
// We show an alert box, here; but you can
// use a window.location= 'http://address'
// to call a subsequent html page,
// or a Perl script, etc.
alert("Information is being sent to Panacea Arts")
METHOD = POST
ENCTYPE = "text/plain"
ACTION = "mailto:allyson@paradise.net.nz?subject=Comments from home"
}
if ((document.TheForm.em.value !=
document.TheForm.emx.value)&&(good)){
alert('Both e-mail address entries must match.')
}
}
</script> </p>
</center></div></font>
</form>
</body>
</html>
Take a look at http://homepages.ihug.co.nz/~usateden/panacea/organisation/enrolment2.htm . The javascript code makes sure that the form is filled in accurately, and when the user clicks 'Send' the alert box comes up, saying that the information has been sent, but the form does not go to the stated email address. I think that I haven't set up the action properly. How could I modify the script, so that action is set up properly? Please help. Thank-you.
<form name="TheForm">
<p><input type="text" name="nm" size="30">Name <br>
<input type="text" name="age" size="5">Age <br>
<input type="text" name="add" size="40">Address <br>
<input type="text" name="city" size="40">City<br>
<br>
<input type="text" name="disability" size="40">Disability<br>
<br>
<input type="text" name="em" size="33"> E-mail address <br>
<input type="text" name="emx" size="33"> Re-enter to confirm </p>
<div align="center"><center><p> </p>
</center></div><div align="center"><center><p><input type="button" value="Submit"
name="SB" onClick="sendOff();"><input type="reset" name="B2" value="Reset"> <script
language="JavaScript1.2">
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
var good;
function checkEmailAddress(field) {
// Note: The next expression must be all on one line...
// allow no spaces, linefeeds, or carriage returns!
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){
good = true
} else {
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
}
function sendOff(){
nmcheck = document.TheForm.nm.value
adcheck = document.TheForm.add.value
agecheck=document.TheForm.age.value
discheck=document.TheForm.disability.value
if (nmcheck.length <1) {
alert('Please enter your name.')
return
}
if (adcheck.length<1) {
alert('Please enter your address.')
return
}
if (agecheck.length<2) {
alert('Please enter your age.')
return
}
good = false
checkEmailAddress(document.TheForm.em)
if ((document.TheForm.em.value ==
document.TheForm.emx.value)&&(good)){
// This is where you put your action
// if name and email addresses are good.
// We show an alert box, here; but you can
// use a window.location= 'http://address'
// to call a subsequent html page,
// or a Perl script, etc.
alert("Information is being sent to Panacea Arts")
METHOD = POST
ENCTYPE = "text/plain"
ACTION = "mailto:allyson@paradise.net.nz?subject=Comments from home"
}
if ((document.TheForm.em.value !=
document.TheForm.emx.value)&&(good)){
alert('Both e-mail address entries must match.')
}
}
</script> </p>
</center></div></font>
</form>
</body>
</html>