By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

getting a newline into an email?

P: n/a
Hello,

I am using prototype.js and part of what is sent to formmail.cgi to be
sent to me by email is a string containing 5 sets of numbers.

I would like to put some carriage return characters in so that these 5
sets are each displayed on a separate line in the email.

How do I do this? I have tried adding "\n", <br>, e and
.....!

Cheers

Geoff
Sep 13 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Geoff Cox" <ge*******@notquitecorrectfreeuk.com> wrote in message
news:if********************************@4ax.com...
Hello,

I am using prototype.js and part of what is sent to formmail.cgi to be
sent to me by email is a string containing 5 sets of numbers.

I would like to put some carriage return characters in so that these 5
sets are each displayed on a separate line in the email.

How do I do this? I have tried adding "\n", <br>, e and
....!


You need to insert the real character, not an equivalent.
Try something like this:

cr = String.fromCharCode(13)
document.write(strLine1 + cr + strLine2)
Sep 13 '05 #2

P: n/a
On Tue, 13 Sep 2005 13:27:57 +0100, "Danny@Kendal"
<da***@STOPSPAMghpkendal.co.uk> wrote:
cr = String.fromCharCode(13)
document.write(strLine1 + cr + strLine2)


Danny,

I have tried the code below - is that how you meant? It doesn't work
though! Can you see why? I wonder wether the prototype.js library
which I am using to send the data to the cgi script is removing any
characters?

Geoff

var cr = String.fromCharCode(13)
document.getElementById("Slider1ValueText").innerH TML = "";

for (situation_number = 0; situation_number <7;
situation_number++)
{
document.getElementById("Slider1ValueText").innerH TML += cr +
"Situation Number: " + situation_number + " ";

for (var i = 0; i <
slider_value_situation_number.length; i++)
{
document.getElementById("Slider1ValueText").innerH TML
+= this.slider_value_situation_number[i] + ' ';
}
}

var recipient = "extraemails";
var realname = "SPA Form";
var situation_value = "Social Group";
var url = 'http://website/path/formmail-nms.cgi';
var pars = 'recipient=' + recipient + '&' + 'realname=' + realname
+ '&' + 'Situation=' + situation_value + '&' + 'Name=' + name + '&' +
'Slider Values=' +
document.getElementById('Slider1ValueText').innerH TML;
var myAjax = new Ajax.Updater('Status', url, {method: 'post',
parameters: pars});
}

Sep 13 '05 #3

P: n/a
ASM
Geoff Cox wrote:
Hello,

I am using prototype.js and part of what is sent to formmail.cgi to be
sent to me by email is a string containing 5 sets of numbers.

I would like to put some carriage return characters in so that these 5
sets are each displayed on a separate line in the email.

How do I do this? I have tried adding "\n", <br>, e and


in your post here, return cariages seem to be : \r


--
Stephane Moriaux et son [moins] vieux Mac
Sep 13 '05 #4

P: n/a
On Tuesday 13 September 2005 14:39, Geoff
Cox(ge*******@notquitecorrectfreeuk.com) wrote in message
<ub********************************@4ax.com>
On Tue, 13 Sep 2005 13:27:57 +0100, "Danny@Kendal"
<da***@STOPSPAMghpkendal.co.uk> wrote:
cr = String.fromCharCode(13)
document.write(strLine1 + cr + strLine2)


Danny,

I have tried the code below - is that how you meant? It doesn't work
though! Can you see why? I wonder wether the prototype.js library
which I am using to send the data to the cgi script is removing any
characters?


[now posting from home]

That'd be my next thing to look at.

All the normal means of applying a newline/carriage-return don't seem to
work so either you're doing something wrong (nobody's perfect) or the code
somewhere is stripping out newline characters.

On a related note - I posted a comment to the BBC News website and split my
paragraphs apart with an empty line, like I have done with this post, and
it appeared as just one large paragraph on the website.
Sep 13 '05 #5

P: n/a
ASM
PDannyD wrote:
On Tuesday 13 September 2005 14:39, Geoff
Cox(ge*******@notquitecorrectfreeuk.com) wrote in message
<ub********************************@4ax.com>
On Tue, 13 Sep 2005 13:27:57 +0100, "Danny@Kendal"
<da***@STOPSPAMghpkendal.co.uk> wrote:

cr = String.fromCharCode(13)
document.write(strLine1 + cr + strLine2)


Danny,

I have tried the code below - is that how you meant? It doesn't work
though! Can you see why? I wonder wether the prototype.js library
which I am using to send the data to the cgi script is removing any
characters?

[now posting from home]


and that :

<html>
<a href="#" onclick="
var asm = 'hello,%0D%0A%0D%0Athere is a little message to%0D%0Asee '+
'if return carriages%0D%0Aare understood';
alert(asm);
location.href='mailto:tr**@machin.com?'+
'subject=saluti a tuti&body='+asm;
return false;
">mail</a>
</html>

which works fine for me at home
--
Stephane Moriaux et son [moins] vieux Mac
Sep 13 '05 #6

P: n/a
ASM wrote:
[...]

<html>
<a href="#" onclick="
var asm = 'hello,%0D%0A%0D%0Athere is a little message to%0D%0Asee '+
'if return carriages%0D%0Aare understood';
alert(asm);
location.href='mailto:tr**@machin.com?'+
'subject=saluti a tuti&body='+asm;
return false;
">mail</a>
</html>


Using encodeURI with '\n' works for me:

<input type="button" value="Send mail..." onclick="

var asm = 'hello,\nhere is a little message to\nsee '+
'if return carriages\nare understood';
alert(asm);
location.href='mailto:tr**@machin.com?'+
'subject=saluti a tuti&body='+encodeURI(asm);
return false;

">


--
Rob
Sep 14 '05 #7

P: n/a
On Tue, 13 Sep 2005 21:00:21 +0200, ASM
<st*********************@wanadoo.fr.invalid> wrote:

Stephane,

Someone has given me the answer!

I used escape()

ie escape("\n")

!!

Cheers

Geoff

Sep 14 '05 #8

P: n/a
Geoff Cox wrote:
On Tue, 13 Sep 2005 21:00:21 +0200, ASM
<st*********************@wanadoo.fr.invalid> wrote:

Stephane,

Someone has given me the answer!

I used escape()


According to Mozilla:

"The escape and unescape functions do not work properly for
non-ASCII characters and have been deprecated. In JavaScript 1.5
and later, use encodeURI ,decodeURI ,encodeURIComponent , and
decodeURIComponent."
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Predefined_Functions:esc ape_and_unescape_Functions>

[...]


--
Rob
Sep 14 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.