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. Advertising

  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. Advertising

  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. Advertising

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. Brendan Illingworth

    Book on VHDL basics and HDL based design

    Brendan Illingworth, Jan 13, 2006, in forum: VHDL
    Replies:
    2
    Views:
    2,069
    Ralf Hildebrandt
    Jan 13, 2006
  2. Jacob Yang [MSFT]

    Re: Starting basics

    Jacob Yang [MSFT], Oct 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    309
  3. Brian Shannon

    Basics of Javascript

    Brian Shannon, Jun 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    362
    clintonG
    Jun 25, 2004
  4. Simon Harris

    Class Basics (Slightly OT?)

    Simon Harris, May 8, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    358
    Web Team @ Borough of Poole
    May 11, 2005
  5. richard

    back to basics on divisions

    richard, Apr 13, 2008, in forum: HTML
    Replies:
    4
    Views:
    348
    richard
    Apr 14, 2008
Loading...

Share This Page