Log in

View Full Version : ASP string to JS string



DigitalBard
08-21-2008, 03:29 PM
I need to get a value from an ASP string variable into a JavaScript string variable, however if the ASP variable has a single or double-quote in it, it doesn't work.

{% vbText = "this" & Chr(34) & "that" %}
var jsText = '{%=vbText%}';

I get an error.

If I escape the vbString:

{% vbText = "this"that" %}
var jsText = '{%=vbText%}';

I don't get an error, but when I put the text into a form, it displays the HTML entity, not the single quote.

The only thing I can think of is to escape the special chars, but use a JS function to decode them... but I'm not that good at JavaScript, so I need some help writing such a function.

DigitalBard
08-21-2008, 04:28 PM
Never mind..

I didn't need to use JS to update the text fields of the form. I'm escaping the string in a VBScript function which works just fine.

magicyte
09-03-2008, 01:16 AM
Hope you got what you needed.

-magicyte