Solved

Unterminated string Error?

Posted on 2002-07-12
8
458 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 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 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