getting a new line?!

G

Geoff Cox

Hello,

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

document.getElementById("Slider1ValueText").innerHTML
+= 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").innerHTML = "";

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

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

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').innerHTML + "'>",
"<input type='submit' value='send'></form>"
];


document.getElementById("formdata").innerHTML = htmlArray.join(' ');

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

}
 
B

Baconbutty

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.
 
G

Geoff Cox

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
 
G

Geoff Cox

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
 
B

Baconbutty

Sorry, I have not read your code as thoroughly as I should.
input type='hidden' name='Slider Values' value='" +
document.getElementById('Slider1ValueText').innerHTML

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").innerHTML

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

Baconbutty

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').innerHTML".

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

Geoff Cox

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").innerHTML

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").innerHTML = "";

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

document.getElementById("Slider1ValueText").innerHTML +=
"<br>" + "Situation - " + title[situation_number] + ": ";

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

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').innerHTML + "'>",
"<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)'>";
}
 
B

Baconbutty

document.getElementById("Slider1ValueText").innerHTML
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.

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").innerHTML = "";
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] +
' ';
}
}

// USE IF YOU WANT TO DISPLAY IT
//document.getElementById("Slider1ValueText").innerHTML = 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();

}
 
G

Geoff Cox

On 4 Oct 2005 06:41:21 -0700, "Baconbutty" <[email protected]>
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").innerHTML = "";
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] + ' ';
}
}

// USE IF YOU WANT TO DISPLAY IT
//document.getElementById("Slider1ValueText").innerHTML =
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();

}
 
B

Baconbutty

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.
 
G

Geoff Cox

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
 
G

Geoff Cox

On 4 Oct 2005 07:49:29 -0700, "Baconbutty" <[email protected]>
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
 
B

Baconbutty

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.
 
G

Geoff Cox

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
 

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,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top