[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Unterminated string Error?

Posted on 2002-07-12
8
Medium Priority
?
461 Views
Last Modified: 2012-05-05
Hi ,
I have the following code

<%
dim strFromDB
'let say that this is the value returned from a db, probably feed line or carriage return
'strFromDB="this is line 1
'           this is line 2"

%>
<script>

var jsstrfromdb='<%=strFromDB%>';>
because the value coming from DB is in two lines, it gives me a javascript error.
I am trying to use server.htmlencode, unescape... but does not work.
Any suggestion.

Thanks.
Nesifa
0
Comment
Question by:nesifa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:mberumen
ID: 7149658
try the replace function

newText=replace(strFromDB,vbcrlf," ")

assuming that your EOL character is vbcrlf  (carriage return, line feed)

you can also evaluate and replace chr(10) or Chr(13)
0
 

Author Comment

by:nesifa
ID: 7149859
vbcrlf equals to what chr(100 or chr(13). I did do vbcrlf but that did not work.
Thanks.
0
 
LVL 4

Accepted Solution

by:
mberumen earned 200 total points
ID: 7149913
I believe is chr(10)+chr(13)

i.e  replace (text, chr(10)+chr(13),"")

BTW.  this is the VBScript sintaxis, Just noticed that you are using JScript  Not sure what is the corresponding statement in JScript.  You might have to write your own replace statement.  
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Expert Comment

by:drittich
ID: 7149925
How you handle the line feed depends upon what you are doing with jsstrfromdb.  Can you explain that part?
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7150516
Try the following which will replace Carriage returns, line feeds both singularly and together with the correct javascript character literal.


var jsstrfromdb='<%=replace(replace(replace(strFromDB,vbcrlf,"\n"),vbcr,"\r"),vblf,"\f")%>';>


If you just want to remove the character(s) then use the following

var jsstrfromdb='<%=replace(replace(strFromDB,vblf,""),vbcr,"")%>';>

Steve

0
 

Expert Comment

by:dotjock
ID: 7151999
Another suggestion.  use the replace function to replace the carrage return with a <p> tag.. or possibly a <br> tag.

something such as this

sVal = replace(sVal, vbCrLf, "<p>")

I usually find it best to replace all carrage returns with <br> so that you dont miss out on a new line.

0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 7153256
Nope, mberumen.
vbCrLf = chr(13)+chr(10)
0
 
LVL 4

Expert Comment

by:mberumen
ID: 7154596
Thanks for setting the record straight GreenGhost.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question