---> PHP SOS
- Started
- Last post
- 11 Responses
- illtronix
how can I pass the value of a TEXTAREA to PHP while maintaining linebreaks? (just like posting to Newstoday). the js object for the teextarea value keeps the linebreaks but when I pass to PHP, it comes out as one long paragraph even when I make new paragraphs.
- illtronix0
actually I think I might have it. I guess I have to go through the textarea.value before it gets submitted, find line breaks and insert BR tags there. is this too convoluted?
Any help would still be appreciated.
thanks.
- intoxicated0
Actually your on the right track. U must find and replace all "
" with before you output the data.For example:
$textmessage = eregi_replace ("", "", $textmessage);
Goto http://www.php.net for more info and seacrh for "eregi_replace"
(I don't really think this is the best place for PHP related problems, but I thought I would show off a bit)
- intoxicated0
<--- the site extracted some of the code in my last post. (See NT uses it too!) Hopefully it will make some sense.
- alienlb0
try this:
$txtWithBreak = nl2br ($txtWithoutBreak);
- illtronix0
alienlb and intoxicated thanks for your insight. very very helpful!
true intoxicated, this isnt the *best* place but it aint too bad either. I can ask a newbie quesion w/o being ignored for a month
;-)
- intoxicated0
Yep, your right about that and aldo smart enough to know which is the best server-side scripting language - keep with it!!!
- xpedious0
$message = nl2br($message);
replaces every
with a
- illtronix0
i heard that. so fuckin easy to work w and build functioning shit w/. Lovin it. dont know why I hadnt started sooner
- illtronix0
ok, heres another newbie Q
where in the form to I place this PHP string replace function? Or should I just write an js string.replace() at an onSubmit inside the form tag?
- kappa0
you need to rethink how this will work.
you want to take the value of the form AFTER it's been submitted and change the line breaks to ""'s. The best way is to use "nl2br($str);" on the form processing page, after the form values have been sent.
- illtronix0
thanks kappa
actually someone had emailed me that very same advice. I thought for some reason that the linebreaks were gone for good after the form was submitted, so now I know better.
still tryingto get my head around some basic concepts. ;-)