Solved

<pre> tag and Text Area

Posted on 2000-02-16
4
277 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
Comment Utility
Adjusted points to 25
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

12 Experts available now in Live!

Get 1:1 Help Now