Forums Register Login

Escape Carriage Returns

+Pie Number of slices to send: Send
Hi all - hope someone can help.
I have a JSP with a description field which is a textarea.
I pass into the JSP the value I want displayed.
If this string has a carriage return in it, it throws a JavaScript error (Unterminated String Constant) when I try to set the value of the text box...
ie
String is "This is
the description"
in the jsp - (note - typed, not actual code so ignore any code errors)
var str = request.getParameter("desc");
mytextbox.value = str;
In the html, this looks like
mytextbox.value = "This is
the description"
How can I escape the carraige return so that it dosnt cause the error?
D
+Pie Number of slices to send: Send
Dave
You should be able to use the '\n' escape to do that.
+Pie Number of slices to send: Send
yeah Dave, Dave is right.
Dave
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 971 times.
Similar Threads
Help me with: String manipulation
HELP with Carriage Returns
BASE64Encoder
How to return a String buffer
strange problem in comments.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:52:45.