Display textarea content with line breaks in html page
January 31, 2008 at 12:21 pm 2 comments
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>”)
Entry filed under: Technical. Tags: html, javascript, php, ruby.
1.
Sri | February 1, 2008 at 6:56 am
Hey,
Very informative. Keep sharing ur knowledge
2.
Sanjay | February 1, 2008 at 7:04 am
Yes, See the implementation here.
http://www.bumpedinto.com/goal/bintos/365