This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript runtime error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript runtime error" Watch "JavaScript runtime error" New topic
Author

JavaScript runtime error

Sat Kum
Greenhorn

Joined: Jul 16, 2002
Posts: 5
I have a function in my JSP and am calling it when the user clicks on an image.

I get a runtime error
"Unterminated string constant"
I tried all possibilities like using escape characters, removing double quotes ..etc.
do anyone have an answer..?
[ July 16, 2002: Message edited by: Sathish ]
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Hi,
in your example single quote, right before "javascript:" closed inside word Provider'2
And if you use onclick, you don't need "javascript:".
<img src="../images/edit_button.gif" border="0"
on_click='OnClickEdit("SunLife","Provider\'2","909090909");'>....
Sat Kum
Greenhorn

Joined: Jul 16, 2002
Posts: 5
Hi,
What if the the single quote's position in the string varies dynamically..?
Sathish
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

Sathish
i agree with what Yuriy said. also, i thought single quotes were used inside double quotes. i dont see any double quotes enclosing the single quotes. otherwise Yuriy's code looks right to me(it's been a while but i seem to recall using \ to escape special chars). semicolon at end is not needed either although it is allowed.

<img src="../images/edit_button.gif" border="0"
on_click="OnClickEdit('SunLife','Provider\'2','909090909')">....

I hate to say this but, your name does not comply with the Javaranch naming guidelines which can be found at http://www.javaranch.com/name.jsp
please register again with a valid name.
[ July 17, 2002: Message edited by: Randall Twede ]

SCJP
Visit my download page
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

if single quote position varies dynamically, i think you are out of luck. it has a meaning to html and must be escaped to not be interpreted.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
look at this thread http://www.coderanch.com/t/113011/HTML-JavaScript/Check-special-characters
It looks simular to your question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript runtime error
 
Similar Threads
Javascript error : help
Error in HTML
Object creation issue wiht Javascript.
Problem with javascript include
Setting dynamic parameter values?