• Post Reply Bookmark Topic Watch Topic
  • New Topic

Escape Carriage Returns

 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave
You should be able to use the '\n' escape to do that.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah Dave, Dave is right.
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!