Solved

<pre> tag and Text Area

Posted on 2000-02-16
4
278 Views
Last Modified: 2010-04-09
Hi,
 
I've a text area....I'm typing characters continuously without pressing enter....Then,I'm getting the textarea's contents and displaying in a table's cell....
I'm using <pre> tag inside my table to preserve the blank line(if any)....
It is getting displayed in one line(as I've typed characters in my textarea without pressing enter)....Is there any method/style that can be set in <pre> tag/<TR>tag that each line should take 15 chracters (say) and the 16th character should goto the next line...
Or,is there any way that I can set in text area the same?.That is,each line should take 15 characters and entering the 16th character is equivalent to pressing enter and entering that character...
Any ideas/suggestions will be greatly helpful forme....
0
Comment
Question by:tmmet
4 Comments
 

Author Comment

by:tmmet
ID: 2527981
Adjusted points to 25
0
 
LVL 28

Expert Comment

by:sybe
ID: 2528447
Don't use the <PRE> tag, but use another method to preserve blank lines: Replace the hard returns with <BR> when displaying the text.

That is the way it works in this message board to (look at the source code of your question: it contains <br>, but you never typed them...

You should be aware that different platforms have different coding for hard returns:

Unix: ASCII 10 + ASCII 13
PC: ASCII 10
MAC: ASCII 13


0
 
LVL 1

Expert Comment

by:dmaryakh
ID: 2528457
You could process the data that you have in your textarea to insert new lines before you display them in your table cell

function formatStr(someStr){
   var returnStr ="";
   for(var i=0; i<someStr.length; i++){
      if ((i%15)==0){
          returnStr+="\n";
          // returnStr+="<BR>";
      }
      returnStr+=someStr.charAt(i);
   }
   return returnStr
}
0
 
LVL 2

Accepted Solution

by:
freshmeat earned 25 total points
ID: 2530032
try this:


<form name=formsname action=... method=post>
<textarea name=xxx cols=15 wrap=hard></textarea>
....
<input type=submin>
</form>



then u can use <pre> to print out ur text content looks like when u type it in the textarea

:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML and CSS for a complex page 20 61
Date / Time format from SQL Row in Powershell Script 2 24
Tags from access to excel 3 30
Getting Column Height to Match Other Column 5 44
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now