Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP - JavaScript

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am invoking JavaScript from a JSP. I am passing a string value from a JSP variable to the JavaScript function. If this string contains a ' (single quote), then the JavaScript fails.
eg: When I call the function as follows => (the variable remarks contains a single quote in that string.)
onClick='openWin(<%= remarks %> )'
Pls. help. Is there any way out that I can get rid of this ???
 
Ramneek Handa
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use onClick="openWin(<%= remarks %> )"
or
onClick=openWin("<%= remarks %>" )
instead of onClick='openWin(<%= remarks %> )'
and it will work.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"bhushans",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic