Dogward Posted May 26, 2008 Share Posted May 26, 2008 Hi ! I just want to know if there is a simple way for 'parsing' TextBox newlines (nl) with javascript... Let's say I have a textbox: <textarea name="test_box" id="test_box">this is a sample multilines text to show everyone</textarea> I would like to be able to get the entire 'test_box' value (multi-lined) get in a javascript var If I just do var test_box_value = document.getElementById('test_box').value; The test_box_value variable will have this value: 'this is a samplemultilinestext to show everyone' What can be done ? thanks. PS: urgent Link to comment Share on other sites More sharing options...
0 Kudos Veteran Posted May 26, 2008 Veteran Share Posted May 26, 2008 I don't know what you mean by parse, here's a newline to html linebreak regular expression. str.replace(/([^>])\n/g, '$1<br />\n'); Link to comment Share on other sites More sharing options...
0 Zoea Posted May 26, 2008 Share Posted May 26, 2008 Parsing in this context (See 'Original Post' of this thread) would mean evaluating content of computer textual input area in some ordered way would it not? [Adjective ~] Parse is also used for (or "as in") literacy and so fourth naturally - - - - of course! Link to comment Share on other sites More sharing options...
0 Dogward Posted May 26, 2008 Author Share Posted May 26, 2008 I don't know what you mean by parse, here's a newline to html linebreak regular expression. str.replace(/([^>])\n/g, '$1<br />\n'); Thanks a lot ! it was not what I expected, but it will do the job quite fine. Thanks again (this thread may be closed). Link to comment Share on other sites More sharing options...
0 Dick Montage Posted May 26, 2008 Share Posted May 26, 2008 \n = new line in JavaScript. But what Kudos showed you will take any text and create it as multiline text. Link to comment Share on other sites More sharing options...
Question
Dogward
Hi !
I just want to know if there is a simple way for 'parsing' TextBox newlines (nl) with javascript...
Let's say I have a textbox:
I would like to be able to get the entire 'test_box' value (multi-lined) get in a javascript var
If I just do
The test_box_value variable will have this value: 'this is a samplemultilinestext to show everyone'
What can be done ?
thanks.
PS: urgent
Link to comment
Share on other sites
4 answers to this question
Recommended Posts