• Post Reply Bookmark Topic Watch Topic
  • New Topic

Web text wrap - Urgent  RSS feed

 
Jim Vamvakitis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a textarea in html and I want to wrap a line no more than 30 characters, without chopping the word. Also, I have to take into consideration many spaces and empty lines. Could anyone show me how I can write this function? Any help would be greatly appreciated? Thanks,
For example user inputs from the web textarea field (wrap at 30 words):
From:
One feature of the war in Iraq was the speed and immediacy with which many events were reported by the media.
Some of these turned out to be not quite what they seemed, others are still surrounded by confusion.
Was this the fog of war, effects-based warfare, propaganda, or error?
To:
One feature of the war in Iraq
was the speed and immediacy
with which many events were
reported by the media.
Some of these turned out to be
not quite what they seemed,
others are still surrounded by
confusion.
Was this the fog of war,
effects-based warfare,
propaganda, or error?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim,
Welcome to JavaRanch. Maybe a class like this:

Here's the output:
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep the user's input in a textarea.
But when you want to display it read-only, use something like
<textarea wrap="virtual" cols="30" rows="10" style="border:none" readonly>
Netscape 4 ignores the readonly attribute. But if you don't include name=, the fact that the user can type into the textarea doesn't have any effect.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently, I was under the erroneous impression that this was a Java forum.
 
Jim Vamvakitis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is with dealing with empty spaces and lines. For example, between the words "the" and "war", I want to be able to keep 3 extra space. And the same thing goes with lines. If the user wants to keep 2 or more line spaces between paragraph the function should be able to handle. Anyways, this is where I'm having problems. I need help urgently and any ideas or help, I would be really appreciated. Thanks.
1- spaces
One feature of the war in Iraq ....
2 - lines
One feature of the war in Iraq was the speed and immediacy with which many events were reported by the media.
Some of these turned out to be not quite what they seemed, others are still surrounded by confusion.
Was this the fog of war, effects-based warfare, propaganda, or error?
 
bob leduc
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The textarea wrap should be "physical".
Originally posted by Michael Zalewski:
Keep the user's input in a textarea.
But when you want to display it read-only, use something like
<textarea wrap="virtual" cols="30" rows="10" style="border:none" readonly>
Netscape 4 ignores the readonly attribute. But if you don't include name=, the fact that the user can type into the textarea doesn't have any effect.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!