Results 1 to 3 of 3

Thread: ASP string to JS string

  1. #1
    Join Date
    Aug 2007
    Location
    Kansas, USA
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default ASP string to JS string

    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.
    Last edited by DigitalBard; 08-21-2008 at 03:30 PM. Reason: formatting

  2. #2
    Join Date
    Aug 2007
    Location
    Kansas, USA
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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.

  3. #3
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Hope you got what you needed.

    -magicyte

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •