note 28723 deleted from function.nl2br by aidan

From: Date: Sun, 10 Oct 2004 10:37:38 +0000
Subject: note 28723 deleted from function.nl2br by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78277@lists.php.net to get a copy of this message
Note Submitter: jotkailay at NOSPAM dot hotmail dot com ---- Hello, I got stuck on this one for a while. If you want to store the data entered as is in the database, but then read it in as a javascript variable so it can be displayed optionally in a textarea (for example, I have a text area that changes its info depending on which show option is clicked) then you need to do this : Say you get comments fro the database : $comments = $row{'comments'}; Then to make it available to javascript variable do : $comments = str_replace("\r\n", "\\r\\n", $comments); Now you can feed $comments as javascript information, otherwise javascript sees \r\n as actual breaks in the string, and you cannot have a multiple line javascript variable. nl2br won't work since a textarea will not parse out the br as breaklines. Thanks for all the help elsewhere on this amazing site, Jot

« previous php.notes (#78277) next »