473,325 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

linebreak on preview

On this page, and others like it:

http://46dems.com/larc/contact.previewtest.php

I have a preview function:

function PreviewButton_onclick() {
var messagesubject = "Subject: " +
document.getElementById('subject').value;
var messagebody = document.getElementById('body').value;
var sendername = document.getElementById('firstname').value + " " +
document.getElementById('lastname').value;
var senderaddress = document.getElementById('address').value;
var sendercity = document.getElementById('city').value;
var senderstate = document.getElementById('state').value;
var senderzip = document.getElementById('zip').value;
var senderphone = document.getElementById('phone').value;
var previewtext = messagesubject + "<br><br>" + messagebody +
"<br><br>" + sendername + "<br>" + senderaddress + "<br>" +
sendercity + ", " + senderstate + " " + senderzip + "<br>" +
senderphone;
document.getElementById('previewdiv').innerHTML = previewtext;
}

The issue seems to be that linebreaks are not included in the
preview. I don't know how to identify where those are and how to get
them to show up correctly.

Can anyone help?

Chad

Feb 19 '07 #1
1 1121
On Feb 19, 11:59 am, "chadlupkes" <chadlup...@gmail.comwrote:
On this page, and others like it:

http://46dems.com/larc/contact.previewtest.php

I have a preview function:

function PreviewButton_onclick() {
var messagesubject = "Subject: " +
document.getElementById('subject').value;
var messagebody = document.getElementById('body').value;
If those elements are in a form, why not use the form's elements
collection and save yourself a lot of typing? I'll presume that
you've supplied names that are the same as the IDs so that non-
scripted or script-disabled browsers will still submit the form:

var f = document.getElementById('formID');
var messagebody = f.elements['body'].value;
...

[...]
var previewtext = messagesubject + "<br><br>" + messagebody +
"<br><br>" + sendername + "<br>" + senderaddress + "<br>" +
sendercity + ", " + senderstate + " " + senderzip + "<br>" +
senderphone;
document.getElementById('previewdiv').innerHTML = previewtext;

}

The issue seems to be that linebreaks are not included in the
preview. I don't know how to identify where those are and how to get
them to show up correctly.

Can anyone help?
Presumably one of them (messagebody?) is a textarea element and you
want to replace line-breaks with BR elements. One of these should
help:

"How to display TextArea value in <SpaninnerHTML with <brin
Netscape"
<URL:
http://groups.google.com.au/group/co...0025149b4f27ae
>
"Problem with innerText/textContent"
<URL:
http://groups.google.com.au/group/co...50650b0c6dd546
>

--
Rob

Feb 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: nAmYzArC | last post by:
Hi everyone, I'm setting the body of an email using values from a form firstname = bob lastname = dole ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname ...
7
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to...
1
by: sea | last post by:
I have Access 2002 and I am writing this application with a custom menu bar that has a print preview button -- the start up options hide the design window. The problem is that when an open form is...
4
by: Dirk Reske | last post by:
Hey, I have following struct: struct Packet { string Command; byte data; }
0
by: Shawn Mehaffie | last post by:
I am creatign a screen saver and am having a problem with showing the screensaver form in the preview pane. The code works correctly in the the form does display within the preview window. I created...
2
by: Georg Weiler | last post by:
Hi, I have a form, where the user enters text. After submit, the text is then inserted into a PostgreSQL database. So far, so good. The problem is, that most of my users copy&paste their text...
3
by: Michael Hamm | last post by:
My page http://www.math.wustl.edu/~msh210/whatsnew.xml (with XSLT and CSS adding formatting) has a paragraph-type break after "Subscribe to this feed" which, afaIct looking at the source code,...
1
by: bonnie.tangyn | last post by:
Hello All In my ASP page, I use CDONT to send email to client. But, I need to allow user preview and edit the email content before sending it out. Any advices? I have two ASP pages -...
3
by: Per W. | last post by:
Hi, is it possible to have Literal using linebreaks? If i have a textfile with more than 1 line then Literal take all on one line. /Per W.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.