Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

<pre> tag and Text Area

Posted on 2000-02-16
4
Medium Priority
?
290 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 50 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

824 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