Click to See Complete Forum and Search --> : Email forms...generate subj, and body?
Major Maximum
01-08-2003, 02:25 AM
okay, I'm trying to make a script so that when someone enters their name(x) in one field and a certain comment(y) in another field, then pressing a button, it will generate and send an email to me saying:
"hello, my name is (x) and i am asking for (y)."
is this possible?
if so, would someone explain what the code would be?(im new to java but i know HTML pretty well....this is urgent for a site I am making)
Try something like that :
<html>
<head>
<script language="JavaScript">
<!--
function sendMail()
{
form = document.fillform;
name= form.Name.value;
comment = form.Comment.value;
document.message.mailer.value = "Hello, my name is "+name+" and I'm asking for "+comment;
document.message.submit();
}
//-->
</script>
</head>
<body>
<form name=fillform action="">
Name:<input type="Text" name="Name" value=""><br>
Comment:<input type="Text" name="Comment" value="">
<input type=button value="GO" onclick="sendMail()">
</form>
<!-- that the submitting form, set your emailaddress below //-->
<form name="message" action="mailto:yours@yourdomain.com" method="post">
<input type="hidden" name=mailer>
</form>
<!-- that the submitting form //-->
</body>
</html>
Major Maximum
01-09-2003, 01:28 AM
well, it generates the forms, but when i click okay or whatever, my email prog(msn) pops up. the subject and body mattter is nowhere to be found.
Ops, didn't see that, well try with that:
<html>
<head>
<script language="JavaScript">
<!--
function sendingMail(mailaddr)
{
subj = "Website Mail";
form = document.fillform;
var name= form.Name.value;
var comment = form.Comment.value;
bodys = "Hello, my name is "+name+" and I'm asking for "+comment;
window.location.href = "mailto:"+mailaddr+"?subject="+subj+"&body="+bodys;
}
//-->
</script>
</head>
<body>
<form name=fillform action="">
Name:<input type="Text" name="Name" value=""><br>
Comment:<input type="Text" name="Comment" value="">
<input type=button value="GO" onclick="sendingMail('yours@yourdomain.com')">
</form>
</body>
</html>
I've updated my code above, now is also subject and body defined.
Major Maximum
01-10-2003, 01:31 AM
wow, swon, thanks a lot!