PDA

View Full Version : How can I e-mail a form without the default mail application


Bluemoon1227
09-10-2002, 02:18 AM
Hello,

I'm fairly new to Javascript and I've been trying to figure this out for a while. I've included the code below, but here's the issue i'm having: I've created a page with a form on it which includes a text area that the user should be able to send to my e-mail address. The problem is that when the user clicks on "send," their default e-mail application comes up, therefore making the text area totally unnecessary to get to this site you can just go to http://www.ithaca.edu/students/arojas1 and click on the "Contact Me" link in the navigation bar. Should I just turn this into a link? Is it possible to do this? Thank you so much for taking the time to help. Here's the code and below it will be the function that the form calls "MM_validateForm":


<form name="Contact" enctype="text/plain" method="post" action="mailto:arojas1@ithaca.edu">
<div align="center">
<p>
<textarea name="message" cols="50" onSubmit="MM_validateForm('message','','R');return document.MM_returnValue" rows="10" wrap="VIRTUAL"></textarea>
</p>
<p class="button">
<input type="submit" name="Submit" value="Send" class="button">
<input type="reset" name="Reset" value="Clear">
<input type="hidden" name="ToEmailAddress" value="arojas1@ithaca.edu">
</p>
</div>
</form>

Function "MM_validateForm":

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

umm
09-10-2002, 05:04 AM
personally, if you don't have a servr-side form handling capability I'd stick with a plian old mailto: link (nothing wrong with them anyway).

Here's a link that might help give you some flexability:

http://developer.netscape.com/viewsource/husted_mailto/mailto.html

Spookster
09-10-2002, 03:32 PM
As was stated in order to send form data to your email without using the clients email program then you have to use a server-side language and use the sendmail feature of that language. You server supports php as evidenced by the rest of the school's website. If they allow you to use php in your site then you can use php to send the emails.

xshao
09-11-2002, 10:50 PM
In your example, the sentence was not printed fully. Any ideas, please. Thanks.