Knowledge Base

January 31, 2008

Display textarea content with line breaks in html page

Filed under: Technical — Tags: , , , — rkutti @ 12:21 pm

Let us see how javascript, php, and ruby display the content of textarea with line breaks

Javascript:

document.getElemnetById(‘textareacontent’).value.replace(/\n/g,’<br>’);

PHP:

preg_replace(“/\n/”,”<br>”,$_REQUEST['t1']);

Ruby:

(teaxtareacontent).gsub(/\n/,”<br>”)

2 Comments »

  1. Hey,
    Very informative. Keep sharing ur knowledge :)

    Comment by Sri — February 1, 2008 @ 6:56 am

  2. Yes, See the implementation here.
    http://www.bumpedinto.com/goal/bintos/365

    Comment by Sanjay — February 1, 2008 @ 7:04 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.