Solved

Unterminated string Error?

Posted on 2002-07-12
8
453 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
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 50 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now