Back to Basics

Discussion in 'ASP General' started by John Peach, Jun 18, 2007.

  1. John Peach

    John Peach Guest

    How to i pass an asp array to a client side vbscript array ?

    Thanks

    John
     
    John Peach, Jun 18, 2007
    #1
    1. Advertisements

  2. John Peach

    Evertjan. Guest

    John Peach wrote on 18 jun 2007 in microsoft.public.inetserver.asp.general:

    > How to i pass an asp array to a client side vbscript array ?


    Assuming serverside vbs and an array of strings:

    <script type = 'text/vbscript'>
    dim a(17)
    a(0) = "<% = a(0) %>"
    a(1) = "<% = a(1) %>"
    a(2) = "<% = a(2) %>"
    a(3) = "<% = a(3) %>"
    '' .....
    </script>

    or

    <script type = 'text/vbscript'>
    dim a(17)
    <%
    for i = 0 to 17
    %>
    a(<% = i %>) = "<% = a(i) %>"
    <%
    next
    %>
    </script>

    or

    As a string by using join() and split()

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 18, 2007
    #2
    1. Advertisements

  3. John Peach

    Justin Piper Guest

    On Mon, 18 Jun 2007 04:25:40 -0500, John Peach <>
    wrote:

    > How to i pass an asp array to a client side vbscript array ?


    If you're careful, one way would be to take a page from JSON and return
    the data as VBScript source:

    <% Option Explicit

    Randomize
    Dim a: a = Array(Fix(Rnd * 100), Fix(Rnd * 100), Fix(Rnd * 100))
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <title>Test</title>
    <script language="vbscript">
    Option Explicit

    Function DisplayData(values)
    Document.GetElementById("output").InnerHTML = Join(a, ", ")
    End Function
    </script>
    <body>
    <div id="output"></div>
    <script language="vbscript">
    Option Explicit

    Dim a: a = Array(<%= Join(a, ", ") %>)
    DisplayData(a)
    </script>
    </body>

    --
    Justin Piper
    Bizco Technologies
    http://www.bizco.com/
     
    Justin Piper, Jun 18, 2007
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joby
    Replies:
    0
    Views:
    1,847
  2. sylvia sil
    Replies:
    1
    Views:
    844
    Curt_C [MVP]
    Dec 29, 2004
  3. =?Utf-8?B?Z29yaWxsYQ==?=
    Replies:
    1
    Views:
    1,014
    Masudur
    May 25, 2007
  4. richard

    back to basics on divisions

    richard, Apr 13, 2008, in forum: HTML
    Replies:
    4
    Views:
    436
    richard
    Apr 14, 2008
  5. Author
    Replies:
    6
    Views:
    3,612
    George
    Jan 22, 2009
  6. martin

    Reading a file twice, back to back ?

    martin, Apr 16, 2006, in forum: Perl Misc
    Replies:
    16
    Views:
    333
  7. Bruno

    Back (history.back()) after refresh

    Bruno, May 29, 2006, in forum: Javascript
    Replies:
    2
    Views:
    488
    Bruno Lopes
    May 30, 2006
  8. Useful Info

    Firefox back button takes me back 2 pages.

    Useful Info, Jun 3, 2007, in forum: Javascript
    Replies:
    0
    Views:
    507
    Useful Info
    Jun 3, 2007
Loading...