Hi All
I need to sent a form via email. Unfortunately I can't use server side for this. At least at the time being.
I want:
a) send it behind the scene, i.e. without opening the e-mail window;
b) fill the e-mail's body with form data in nice looking way: not in pairs name=value, but something like "Name: your value".
By experiment I found that to fulfil the a) I must use POST method. But in this case message's body comes exactly in name=value pairs.
If I use GET I'm in control of body appearance but can't make it into lines - \r and \n do not work at all, \b gives a new line but also a square at the end of each line, like "Name: myname"
This is how I'm doing this:
<script type="text/javascript">
function sendEmail()
{
var send_form = document.all.ser_req;
var addr="[email protected]";
var subj="test server request";
var body_text="Please ... blah-blah-blah...:";
body_text+="\b Officer: "+document.all.officer.value;
body_text+="\b Phone: "+document.all.phone.value;
body_text+="\b Server Requirements: "+document.all.server_reqs.value;
body_text+="\b Operating System Requirements: "+document.all.sys_reqs.value;
body_text+="\b Application: "+document.all.application.value;
body_text+="\b Additional comments: "+document.all.comments.value;
send_form.action="mailto:"+addr+"?subject="+subj+"&body="+body_text;
send_form.method="post";
send_form.submit();
}
</script>
</head>
<body>
<form id="ser_req">
.....
.....
<input type="button" name="ok" value=" OK " onclick="sendEmail();"/>
</form>
So, the question is: is it possible to implement both a) and b)?
If not, how to resolve 'new line' problem.
Thanks
I need to sent a form via email. Unfortunately I can't use server side for this. At least at the time being.
I want:
a) send it behind the scene, i.e. without opening the e-mail window;
b) fill the e-mail's body with form data in nice looking way: not in pairs name=value, but something like "Name: your value".
By experiment I found that to fulfil the a) I must use POST method. But in this case message's body comes exactly in name=value pairs.
If I use GET I'm in control of body appearance but can't make it into lines - \r and \n do not work at all, \b gives a new line but also a square at the end of each line, like "Name: myname"
This is how I'm doing this:
<script type="text/javascript">
function sendEmail()
{
var send_form = document.all.ser_req;
var addr="[email protected]";
var subj="test server request";
var body_text="Please ... blah-blah-blah...:";
body_text+="\b Officer: "+document.all.officer.value;
body_text+="\b Phone: "+document.all.phone.value;
body_text+="\b Server Requirements: "+document.all.server_reqs.value;
body_text+="\b Operating System Requirements: "+document.all.sys_reqs.value;
body_text+="\b Application: "+document.all.application.value;
body_text+="\b Additional comments: "+document.all.comments.value;
send_form.action="mailto:"+addr+"?subject="+subj+"&body="+body_text;
send_form.method="post";
send_form.submit();
}
</script>
</head>
<body>
<form id="ser_req">
.....
.....
<input type="button" name="ok" value=" OK " onclick="sendEmail();"/>
</form>
So, the question is: is it possible to implement both a) and b)?
If not, how to resolve 'new line' problem.
Thanks
Comment