IntelliJ Java IDE
The moose likes Servlets and the fly likes JSP - JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "JSP - JavaScript" Watch "JSP - JavaScript" New topic
Author

JSP - JavaScript

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Nov 10, 2000
Posts: 44
use onClick="openWin(<%= remarks %> )"
or
onClick=openWin("<%= remarks %>" )
instead of onClick='openWin(<%= remarks %> )'
and it will work.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
"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.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
 
 
subject: JSP - JavaScript
 
Threads others viewed
Passing the JSTL variable (with special characters) to JavaScript function?
Assign Jsp variable to Javascript variable
Javascript to JSP
dynamically creating variable names in javascript
JSP & JavaScript Problem
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture