Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preserve formatting when copying and pasting into Web Form

Status
Not open for further replies.

UnDoug

Programmer
Dec 11, 2002
14
US
I've cross posted the following to the Perl forum. Sorry if it's not appropriate for this forum:


Hi,

I'm having a problem with an HTML web form that is generated by a Perl script.

The Perl script first reads in an HTML file and displays it's contents at the top of the page (it's the syllabus for a course taught by a college instructor). Beneath the syllabus, is the web form. The instructor needs to be able to copy from the syllabus and paste into the form's blanks. This all works just fine, but when the instructor clicks submit and it displays what he or she has submitted so that they can make changes if necessary, the text that was pasted in loses its formatting (spacing, tabs, etc.).

I believe this is due to the fact that they are copying and pasting formatted text. When I copied one section of a syllabus web page and pasted it into a blank MS Word document, it displayed automatically as a Table with borders, even though there were no borders in the HTML page it came from.

An additional weird thing is that sometimes it seems to display okay--just the way it looked in the original, but other times it loses all formatting.

Is there anything I can do to guarantee that the spacing at least won't be lost when text is copied and pasted into my form?

Thanks!

Douglas
 
UnDoug, HTML will usually ignore spaces. Unless you specify
Code:
& nbsp;
for each space it will not display the same (especially in different browsers).

And I believe that tabs are not valid characters. If I understand you correctly, the instructor is pasting into a textarea? Correct? Then unless you paste in table tags you will also loose the tab formatting.

Yes, pasting formatted text into Word will produce strange results, Word will attempt to fill in the formatting.

You can use the
Code:
<PRE>
HTML tag to keep the formatting. This won't help with tabs, but it should keep the spacing. If it's a lot of text you may want to run a routine that will create a table dynamically around the text. . . but this gets into another topic.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top