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

getting a new line?!

P: n/a
Hello,

I am trying to get each "Situation - etc" in

document.getElementById("Slider1ValueText").innerH TML
+= escape("\n") + "Situation - " + title[situation_number] + ": ";

to start on a new line in the email which contains the data sent using
<form and formmail-nms.cgi.

I've tried escape("\n") as above, plus \n, \n\r, \\n\\r etc etc but
cannot get it to work. Ideas please?!

Cheers

Geoff
function saveIt()
{

document.getElementById("Slider1ValueText").innerH TML = "";

for (situation_number = 0; situation_number < 7; situation_number++)
{
document.getElementById("Slider1ValueText").innerH TML
+= "Situation - " + title[situation_number] + ": ";

for (var i = 0; i < slider_value[situation_number].length; i++)
{
document.getElementById("Slider1ValueText")
..innerHTML += this.slider_value[situation_number][i] + ' ';
}
}

var htmlArray = [
"<form action='http://website/cgi-bin/formmail-nms.cgi'",
" method='post'>",
"<input type='hidden' name='recipient' value='extraemails'>",
"<input type='hidden' name='realname' value='SPA Form'>",
"<input type='hidden' name='First name' value='" + firstname + "'>",
"<input type='hidden' name='Last name' value='" + lastname + "'>",
"<input type='hidden' name='Slider Values' value='" +
document.getElementById('Slider1ValueText').innerH TML + "'>",
"<input type='submit' value='send'></form>"
];
document.getElementById("formdata").innerHTML = htmlArray.join(' ');

var subForm = document.getElementById("formdata");
subForm = document.getElementsByTagName('FORM')[0];
subForm.submit();

}
Oct 4 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Assuming your e-mail is in HTML format..

I don't think \n is preserved in HTML unless it is in a <PRE> element,
or you have "white-space:pre" set.

Try inserting "<BR>" instead.

Oct 4 '05 #2

P: n/a
On 4 Oct 2005 00:45:01 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:
Assuming your e-mail is in HTML format..

I don't think \n is preserved in HTML unless it is in a <PRE> element,
or you have "white-space:pre" set.

Try inserting "<BR>" instead.


Hello,

I will try that in a second but have just noticed that if I use "\n"
with Firefox I get the new line whereas I do not get it with Internet
Explorer !!??

Cheers

Geoff

Oct 4 '05 #3

P: n/a
On 4 Oct 2005 00:45:01 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:
Assuming your e-mail is in HTML format..

I don't think \n is preserved in HTML unless it is in a <PRE> element,
or you have "white-space:pre" set.

Try inserting "<BR>" instead.


have just tried the <BR> and no go! Odd how the 2 different browsers
affect this?

Geoff

Oct 4 '05 #4

P: n/a
Sorry, I have not read your code as thoroughly as I should.
input type='hidden' name='Slider Values' value='" +
document.getElementById('Slider1ValueText').inner HTML
If I understand it correctly it looks like you are creating a list of
items, separated by "%0A" (or "%OD"), and making this the value of the
hidden input, so my BR suggestion could have been rubbish, particularly
as it involves puting markup in an attribute value.

I don't know what you are doing server side, but have you tried
unescaping the value when it is received by the server?
document.getElementById("Slider1ValueText").inner HTML


Also, why are you using an element for storage, when you could just use
a string variable in script - am I missing something?

Oct 4 '05 #5

P: n/a
Back to my original point - what is the format of the e-mail?

If the e-mail is HTML format, then "\n" is usually stripped out as
whitespace. In which case if you are sending mark-up to the server,
you may as well escape the whole of
"document.getElementById('Slider1ValueText').inner HTML".

If the e-mail is plain text, then you will need to unescape the \n on
the server.

Oct 4 '05 #6

P: n/a
On 4 Oct 2005 03:28:48 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:
document.getElementById("Slider1ValueText").inne rHTML


Also, why are you using an element for storage, when you could just use
a string variable in script - am I missing something?


More lilely to be me that's missing something! Are you saying that I
do not need to use either

document.getElementById("Slider1ValueText").innerH TML

or

document.getElementById("formdata").innerHTML

?? and that I could use string variables??

Cheers

Geoff


function saveIt()
{

mySlider1.setValue( (mySlider1.leftValue +
mySlider1.rightValue) / 2 );

document.getElementById("Slider1ValueText").innerH TML = "";

for (situation_number = 0; situation_number < 7;
situation_number++)
{

document.getElementById("Slider1ValueText").innerH TML +=
"<br>" + "Situation - " + title[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 htmlArray = [
"<form action='http://websitecgi-bin/formmail-nms.cgi'",
" method='post'>",
"<input type='hidden' name='recipient' value='extraemails'>",
"<input type='hidden' name='realname' value='SPA Form'>",
"<input type='hidden' name='First name' value='" + firstname
+ "'>",
"<input type='hidden' name='Last name' value='" + lastname +
"'>",
"<input type='hidden' name='Slider Values' value='" +
document.getElementById('Slider1ValueText').innerH TML + "'>",
"<input type='submit' value='send'></form>"
];
document.getElementById("formdata").innerHTML = htmlArray.join(' ');

var subForm = document.getElementById("formdata");
subForm = document.getElementsByTagName('FORM')[0];
subForm.submit();

}

function sendbutton()
{
document.getElementById('sendbutton').innerHTML = "<input
type='button' name ='nextbutton' value='Next'
onclick='next_question(this)'>";
}
Oct 4 '05 #7

P: n/a
>document.getElementById("Slider1ValueText").inner HTML
or
document.getElementById("formdata").innerHTML


Just the former - I am not sure why you need Slider1ValueText. The
latter is needed because it is the container for your manufactured
form.
?? and that I could use string variables??


I may be off the mark, and you may be using the Slider1ValueText
element to see what you are doing, but you could try:-

function saveIt()
{
mySlider1.setValue( (mySlider1.leftValue +
mySlider1.rightValue) / 2 );

//document.getElementById("Slider1ValueText").innerH TML = "";
var sValue="";

for (situation_number = 0; situation_number < 7;
situation_number++)
{

// CHOICE COULD DEPEND ON WHAT FORMAT IS EXPECTED AT THE
SERVER
//sValue+="<br>" + "Situation - " +
title[situation_number] + ": ";
sValue+="\n" + "Situation - " + title[situation_number] +
": ";

for (var i = 0; i <
slider_value[situation_number].length; i++)
{
sValue+=this.slider_value[situation_number][i] +
' ';
}
}

// USE IF YOU WANT TO DISPLAY IT
//document.getElementById("Slider1ValueText").innerH TML = sValue;
// I WOULD THEN TRY UNESCAPING IN YOUR CGI SCRIPT
sValue=escape(sValue);

var htmlArray = [
"<form action='http://websitecgi-bin/formmail-nms.cgi'",
" method='post'>",
"<input type='hidden' name='recipient' value='extraemails'>",
"<input type='hidden' name='realname' value='SPA Form'>",
"<input type='hidden' name='First name' value='" + firstname
+ "'>",
"<input type='hidden' name='Last name' value='" + lastname +
"'>",
"<input type='hidden' name='Slider Values' value='" + sValue
+ "'>",
"<input type='submit' value='send'></form>"
];
document.getElementById("formdata").innerHTML = htmlArray.join(' ');

var subForm = document.getElementById("formdata");
subForm = document.getElementsByTagName('FORM')[0];
subForm.submit();

}

Oct 4 '05 #8

P: n/a
On 4 Oct 2005 06:41:21 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:

Julian,

I have tried your code using the sValue variable etc and 1 step
forward at least - both Internet Explorer and Firefox give the same
email result !

Trouble is I am not getting the newline - I see %0ASituation in the
email. Where now?!

Cheers

Geoff

I guess for clarity I had better add the code which I used ...
function saveIt()
{
mySlider1.setValue( (mySlider1.leftValue +
mySlider1.rightValue) / 2 );

//document.getElementById("Slider1ValueText").innerH TML = "";
var sValue="";

for (situation_number = 0; situation_number < 7;
situation_number++)
{
// CHOICE COULD DEPEND ON WHAT FORMAT IS EXPECTED AT THE
SERVER
//sValue+="<br>" + "Situation - " +
title[situation_number] + ": ";
sValue+="\n" + "Situation - " + title[situation_number]
+ ": ";

for (var i = 0; i <
slider_value[situation_number].length; i++)
{
sValue+=this.slider_value[situation_number][i] + ' ';
}
}

// USE IF YOU WANT TO DISPLAY IT
//document.getElementById("Slider1ValueText").innerH TML =
sValue;

// I WOULD THEN TRY UNESCAPING IN YOUR CGI SCRIPT

sValue=escape(sValue);

var htmlArray = [
"<form action='http://website/cgi-bin/formmail-nms.cgi'",
" method='post'>",
"<input type='hidden' name='recipient' value='extraemails'>",
"<input type='hidden' name='realname' value='SPA Form'>",
"<input type='hidden' name='First name' value='" + firstname +
"'>",
"<input type='hidden' name='Last name' value='" + lastname +
"'>",
"<input type='hidden' name='Slider Values' value='" + sValue +
"'>",
"<input type='submit' value='send'></form>"
];
document.getElementById("formdata").innerHTML = htmlArray.join(' ');

var subForm = document.getElementById("formdata");
subForm = document.getElementsByTagName('FORM')[0];
subForm.submit();

}
Oct 4 '05 #9

P: n/a
>Trouble is I am not getting the newline - I see %0ASituation in the
email. Where now?!


You need to "unescape" the input value on th server.

I.e you are sending the string " %0ASituation" to the server.

The following script:-

"http://website/cgi-bin/formmail-nms.cgi'"

needs to use "unescape" (or cgi equivalent) to convert %OA -> to
newline character.

Oct 4 '05 #10

P: n/a
On 4 Oct 2005 07:49:29 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:
Trouble is I am not getting the newline - I see %0ASituation in the
email. Where now?!


You need to "unescape" the input value on th server.

I.e you are sending the string " %0ASituation" to the server.

The following script:-

"http://website/cgi-bin/formmail-nms.cgi'"

needs to use "unescape" (or cgi equivalent) to convert %OA -> to
newline character.


Julian,

I has just occurred to me that I am wrong! The newline is being acted
on when using both IE and Firefox - in that the word "Situation" does
start on a newline each time. The strange thing is that with Firefox
0D0A gets into other parts of the lines disrupting the format. How can
that be happening?!

Cheers

Geoff
1. IE

Situation - Social Individual: 3 3 3 3 3 3 3 3
Situation - Formal Individual: 3 3 3 3 3 3 3 3
Situation - Social Group: 3 3 3 3 3 3 3 3
Situation - Formal Group: 3 3 3 3 3 3 3 3
Situation - Parents: 3 3 3 3 3 3 3 3
Situation - Telephone: 3 3 3 3 3 3 3 3
Situation - 'Scripted' Conversations: 3 3 3 3 3 3 3 3

2. Firefox

Situation - Social Individual: 3 3 3 3 3 3 3 3
Situation - Formal
Individual: 3 3 3 5 3 3 3 3
Situation - Social Group:3 3 3 3 3 3 3 3

Situation - Formal Group: 3 3 3 3 3 3 3 3
Situation - Parents:3 3
3 3 3 3 3 3
Situation - Telephone: 3 3 3 3 3 3 3 3
Situation -
'Scripted' Conversations:3 3 3 3 3 3 3 3


Oct 5 '05 #11

P: n/a
On 4 Oct 2005 07:49:29 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:

Julian,

I need to correct what I said last !!

When I use you last code with the sValue etc - if I remove the
escape(sValue) I get the correct format using both IE and Firefox !!

So it looks as if the problem may be caused by my use of
prototype-1.3.1.js in the other version of this app where I still get
the different formatting with the 2 browsers. Problem here seems to be
that it is difficult to get any help with prototype. Have you ever
used it?
Geoff
Oct 5 '05 #12

P: n/a
>When I use you last code with the sValue etc - if I remove the
escape(sValue) I get the correct format using both IE and Firefox !!
Great. So is it working then? Sorry that it has been a little
difficult to advise, as I do not have the full client/server context in
which the code is running.
So it looks as if the problem may be caused by my use of
prototype-1.3.1.js in the other version of this app where I still get
the different formatting with the 2 browsers. Problem here seems to be
that it is difficult to get any help with prototype. Have you ever
used it?


Sorry, not really looked at this. However, scanning it quickly, it all
looks familiar. I have (as I am sure have most) over the last couple
of years created my own library of some 500 functions, doing pretty
much the same things.

If you think there is a problem with a particular element of
prototype.js, you could always post this.

Oct 5 '05 #13

P: n/a
On 5 Oct 2005 02:28:10 -0700, "Baconbutty" <ju****@baconbutty.com>
wrote:
Sorry, not really looked at this. However, scanning it quickly, it all
looks familiar. I have (as I am sure have most) over the last couple
of years created my own library of some 500 functions, doing pretty
much the same things.

If you think there is a problem with a particular element of
prototype.js, you could always post this.


Julian,

I would like to narrow down the problem but at moment all I can see is
that when using prototype-1.3.1js in the code the two browsers treat
the email data format differently whereas with your code they both
look the same.

Not sure that I can do better!?

Cheers

Geoff

Oct 5 '05 #14

P: n/a
OK. Looks like thats it then.

Cheers

Julian

Oct 5 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.