Forum Moderators: open
If one keeps typing inside the textarea, a horizontal scroll bar appears.. if this data is submitted and viewed on the other page, the table in which this is displayed, increases in width to accomodate the long line of text..
But while typing, if the user goes on next line by pressing enter, it appears perfectly
I guess this is because, I am using wrap="soft"
My requirement is that, while the user types, he/she should be automatically taken to the next line whenever the textarea ends. And the neww line should also get stored so that, it doesnt damage my display table. Just the way this textbox, in which I am typing this post right now is working.
Is there any way to do it in HTML?OR do I need to look at Javascript ?
Thanks
PS: One thing I have observed is that, instead of typing, if I copy paste a pre written paragraph in the textarea, then the text goes on the next line with a vertical scroll bar.. and there after if I make any addition to any of the line, it continues the similar way.. just the way I want it..
And the neww line should also get stored so that, it doesnt damage my display table.
As long as your stored data has spaces in it, it should wrap in any output container. The three exceptions I can think of:
<td nowrap> Content won't wrap</td>
<pre>
Content won't wrap, it's preformatted
</pre>
.container { white-space:nowrap; }
....
<p class="container">Content won't wrap, styled without wrap</p>
So your output issue is one of the page it's output on, and has nothing to do with the original form input.
also checked after removing wrap. But no success.
Suppose I type
this is the *press enter*
message
then it shows
this is the message
in the output container thereby increasing its width which blows up the design
didnt know wrap is deprecated..
Earlier I was under the impression that wrap="hard" stores new line elements when form is submitted and it can be displayed in the same way anywhere else..but I think this is only true if it is displayed in a textarea.. (please correct if I am wrong)
In my case, the form is to edit data so when it loads, it already displays the current value stored in the table..and here it will show the text the way I had typed it. which is
this is the
message
Sorry if I am going out of the scope of this thread.. how can I make it work such that it displays the text in the output container, just the way it was typed..
Thanks for the help.
automatically taken to the next line whenever the textarea ends
This happens by default.
If your looking for return character to also be there with an auto linefeed then your in trouble. There is no easy way of doing this. It can be done using JavaScript, as I've done it long ago on a website that no longer exists, it took me two days to write the JavaScript, so expect some headaches.