unterminated string constant error

unterminated string constant in java or javascript

Page 1 of 1

1 Replies - 2737 Views - Last Post: 09 October 2010 - 11:08 AM

#1 sutr_kam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 15-February 09

unterminated string constant error

Posted 06 October 2010 - 10:41 AM

Hi,
I have code like this

<script type='text/javascript'>
<%
String contactReasonHold = (String)request.getAttribute("CReasonHold");
%>
var crh = "<%= contactReasonHold %>";



if the 'contactReasonHold' value is single line then there is no problem

if it is more than 1 line,
then iam getting javascript error stated above

please help me...

MOD EDIT: Added code tags and moved to Javascript

This post has been edited by JackOfAllTrades: 06 October 2010 - 11:11 AM


Is This A Good Question/Topic? 0
  • +

Replies To: unterminated string constant error

#2 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1167
  • View blog
  • Posts: 7,213
  • Joined: 07-September 06

Re: unterminated string constant error

Posted 09 October 2010 - 11:08 AM

There are a few things you can do here. The first one is the take out all newline characters (\n, and \r) from the string and then output it. This is likely the easiest option. The second is you could add in a \ before all newline characters making Javascript ignore them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1