By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

How to handle Multiple line strings in JavaScript?

P: 2

I have stored some vaue that I am getting from textarea to my mysql db like this

Some Data,Some More Data
some Extra data
some More Extra data

and I am getting that data in JSP page
and I try to access that data in my JSP page using JavaScript

like this
var someValue=
Some Data,Some More Data
some Extra data
some More Extra data

but there is multiple line split problem of string
I try to replace by something like this

and that is not working

any help on this topic
Jul 18 '15 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,032
The might be just linefeeds ("\r") in the text.....

Did you try this too:
Expand|Select|Wrap|Line Numbers
  1. .replace(/\n|\r/,"#")
if this does not help do this to determince which characters are in the text:
Expand|Select|Wrap|Line Numbers
  1. v="Hallo\r\n"
  2. s=""
  3. for (i=0; i<v.length; i++) { s = s + v.charCodeAt(i); }
The output of this example should be:
Jul 18 '15 #2

P: 2

Thanks for replying

Before I can Post first I would like to know If you have to store value of textarea fields in database and preserve all the line breaks that user has typed

and display back that data back in JSP page with JavaScript what will be your approach for this?
Jul 19 '15 #3

Expert 100+
P: 1,032
"JSP page with JavaScript "

JSP = JavaServer Pages

- Java is not equal to JavaScript
- I do not have (enough) knowledge about JSP
- I would display it so the it will look the same ;)
Jul 19 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.