Posted by Andrew Bailey on 11/12/06 09:57
"Michael Fesser" <netizen@gmx.de> wrote in message
news:cpmcl2h1cqflhkjhubjm6c21c3s1ib81q1@4ax.com...
> .oO(M)
>
>>I have searched various news groups and i know i can use the mailto in
>>the way below by hardcoding what it should say.
>
> You cannot use a 'mailto' in a form's action, because it's completely
> undefined and will fail in many cases.
>
>>Is it possible without
>>using (asp or cgi) any scripting to pass the contents of user input in
>>text boxes into the subject and body field to send as an email????????
>
> Form processing always requires a server-side script.
>
> Micha
Here ya go...
(Remember to scamble the mailto: and your domain name) Make an error and
success page too ;)
Andy
<html>
<head>
<title>Transfer Form data to email client</title>
<script type="text/javascript">
<!-- TRANFER FORM TO EMAIL CLIENT
function sendmymail(){
var firstname= document.getElementById('first').value;
var lastname= document.getElementById('last').value;
var mysubject= document.getElementById('subject').value;
var myto=
document.getElementById('dept')[document.getElementById('dept').selectedIndex].value;
var mybody= document.getElementById('emailbody').value;
if (firstname==''){
parent.location="contact us error page.html";
} else if (lastname==''){
parent.location="contact us error page.html";
} else if (mysubject==''){
parent.location="contact us error page.html";
} else if (mybody==''){
parent.location="contact us error page.html";
} else {
document.location.href="mailto:"+ myto+"@yourdomian.com"?subject="+
mysubject +"&body="+ mybody +"%0D%0A%0D%0AFrom "+ firstname +" " + lastname;
parent.location="contact thankyou page.html";
}
}
// - End of JavaScript - -->
</script>
</head>
<body>
<form method="get" id="the id" name="myform">
Your First Name: <input type="text" name="first" id="first" maxlength="30">
<br>
Your Last Name: <input type="text" name="last" id="last" maxlength="30">
<br>
Subject: <input type="text" name="subject" id="subject" maxlength="60">
<br>
Department: <select name="dept" id="dept">
<option value="sales">Sales</option>
<option value="support">Support</option>
<option value="admin">Admin</option>
<option value="order">Order</option>
<option value="delivery">Delivery</option>
<option value="warranty">Warranty</option>
<option value="privacy">Privacy</option>
<option value="cancellation">Cancellation</option>
<option value="personnel">Personnel</option>
</select>
<br>
Your Message: <textarea cols="35" rows="9" name="emailbody"
id="emailbody"></textarea>
<br>
Submit: <input type="submit" value="Submit" name="Submit"
onclick="sendmymail();" title="Click here to SUBMIT your email">
</form>
</body>
</html>
[Back to original message]
|