Line Breaks for <textarea>
Moderator: General Moderators
Line Breaks for <textarea>
Hey!
I have a textarea that is used to submit text for a news posting script, how do I get php to insert line breaks (<br>) automatically when the text wraps in the text box.
Thanks!
I have a textarea that is used to submit text for a news posting script, how do I get php to insert line breaks (<br>) automatically when the text wraps in the text box.
Thanks!
i was looking at the phpbb source code and found this:
does that have anything to do with it?

Code: Select all
<?php
$message = str_replace("\n", "<BR>", $message);
?>- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
I think you mean the nl2br function: http://www.php.net/manual/en/function.nl2br.php
I don't think so...but i found this:
there is also soft and hard. I thing off will make it so when it is submitted, if you hit enter a bunch of times then type a letter, it will show up the same. I'm testing it now.
Code: Select all
<textarea wrap="off">True to the type</textarea>- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
actually, it wouldnt insert a line break when wrapped in the text box, it would insert a break everytime the user hit a line break...
you could tell php to count a certain amount of characters and put a break in though
you could tell php to count a certain amount of characters and put a break in though
Last edited by hob_goblin on Tue May 28, 2002 2:32 pm, edited 1 time in total.
huh? im sry but is there a functionality to putting a "/" at the end here: <br />
Im sry dont understand, I have done fine, just using <br> in my scripts
Im sry dont understand, I have done fine, just using <br> in my scripts
Last edited by mykg4orce on Tue May 28, 2002 2:35 pm, edited 1 time in total.
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
SOFT wraps long lines in the text area for easy editing, much like a word processor. It does not, however, send the carriage returns to the server. This type of wrap is probably the most useful because it is the easiest for the user to edit, but it does not actually change any of their data. HARD looks to the user like SOFT, but the carriage returns the user sees are sent to the server. OFF does not wrap at all; it displays and sends the text exactly as typed in.
Personally I actually preferr to just not mention the wrap in the textarea itself. This because a lot of the time the textarea may be the same width as is allowed for the message as it gets displayed later, but the font size may well be different. Or they may well differ anyway.
In short I like the width allowed for the entered message to be independant of the textarea width.
I usually work with the wordwrap function but apparently it seems as if a lot of php hosts do not have support for that one. Works nicely though.
In short I like the width allowed for the entered message to be independant of the textarea width.
I usually work with the wordwrap function but apparently it seems as if a lot of php hosts do not have support for that one. Works nicely though.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
<br> is HTML and <br /> is XHTML. Basically XHTML is HTML but a bit more strict, all tags have to be closed and be in lowercase and all attributes must be enclosed in double quotes so althoughmykg4orce wrote:huh? im sry but is there a functionality to putting a "/" at the end here: <br />
Im sry dont understand, I have done fine, just using <br> in my scripts
Code: Select all
<IMG SRC="mypic.jpg" WIDTH=12 HEIGHT=45>Code: Select all
<img src="mypic.jpg" width="12" height="45" />Check this thread for more info.
Mac