How to insert text on multiple lines - in "body" of mailto:

G

G. Morgan

<I don't have access to a server-side app. so this must be done client side.>

How do I get:
(thebody)+(dropdown) to appear on their own lines in the resulting email?

I've tried the \n switch in every concievable way but I can't get them on
seperate lines.

Thanks.

CODE:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Feedback Form</title>

<script>
function now()
{
var thebody=document.testform.thebody.value;
var dropdown=document.testform.dropdown.value;
window.location.href="mailto:[email protected]?subject=Mail Test&body=" +
(thebody)+(dropdown);
}
</script>

</head>

<body>

<form name=testform>
<br>
<textarea name=thebody>
This is test.
</textarea>
<br>
<select size="1" name=dropdown>
<option value="yes">yes</option>
<option value="no">no</option>
</select> choose yes or no.</p>
<br>
<input type=button value="click me" onclick="now()">
</form>

</body>
</html>
 
B

Bart Van der Donck

GArlington wrote:

[...]
<a href="mailto:[email protected]?Subject=thisSubject&Body=The message's
first paragraph.%0ASecond paragraph.%0AThird Paragraph.">mailto</a>

An end-of-line character can only be written as %0D%0A here. RFC 2368:

| Also note that line breaks in the body of a message MUST be
| encoded with "%0D%0A".

The example stands a bit further:

| <mailto:[email protected]?body=send%20current-
| issue%0D%0Asend%20index>

Also, spaces are not allowed, they must be written as %20. Apostrophes
can be written as ' or %27, my preference goes to %27. The variables
'thebody' and 'dropdown' must be percent-encoded before they can be
used inside an URI.

All together:

----------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Feedback Form</title>
<script type="text/javascript">
function now() {
var thebody = escape(document.testform.thebody.value);
var dropdown = escape(document.testform.dropdown.value);
window.location.href = "mailto:[email protected]?"
+ "subject=Mail%20Test&body="
+ thebody
+ '%0D%0A'
+ dropdown;
}
</script>
</head>
<body>
<form name="testform" method="get" action="#"
onSubmit="return false;">
<p>
<textarea name="thebody" rows="5" cols="30">This is test.</textarea>
<br>
<select size="1" name="dropdown">
<option value="yes">yes</option>
<option value="no">no</option>
</select> choose yes or no.</p>
<p><input type="button" value="click me" onClick="now();"></p>
</form>
</body>
</html>

----------------------------------------------------------

To the original poster: I've altered your code so that it's now valid
HTML (4.01, transitional), please see validator.w3.org for details.
Also be careful for leading/trailing end-of-line characters inside
<textarea>. I removed them in any case.

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top