Passing Server Side Arrays to Client Side Scripts 
Author Message
 Passing Server Side Arrays to Client Side Scripts

Does anyone know who to retrieve a server side dimensioned array from the
client side using VBScript?  I basically want to execute some vbscript on
the onclick() event of a button that recursively reads in data from a server
side array.  Any help is appreciated.  Thanks in advance.

Thuan Tran



Sat, 22 Jun 2002 03:00:00 GMT  
 Passing Server Side Arrays to Client Side Scripts
The best way to do this is to pre-load the server-side array into a
client-side array when the server-side ASP is processed. Then you can have
your client script to anything you want with the client-side copy of the
array.

To do this iterate the server-side array in server-side ASP script and build
the client-side array in the server-side loop. Here's a quick example in
VBscript:

<%
'Declare the server-side array and some variables
    dim arrServer(2)
    dim intArrSize
    dim n
    intArrSize=UBound(arrServer)
%>
<!-- Create a mirror client-side array with the same size as the server-side
array-->
<script language="vbscript">
    dim arrClient(<% =intArrSize %>)
</script>
<%
'Populate the array server-side with some sample data
    arrServer(0)="Wibbly"
    arrServer(1)="Wobbly"
    arrServer(2)="Woo"
'Loop the server-side array
    for n=0 to intArrSize
%>
<!-- Insert the server-side array data into the client-side array -->
<script language="vbscript">
    arrClient(<% =n %>)="<% =arrServer(n) %>"
</script>
<%
    next
%>
<!-- Display the client-side array so we know it worked -->
<script language="vbscript">
dim n
    for n=0 to UBound(arrClient)
        alert(arrClient(n))
    next
</script>

Hope this gives you some ideas.

--
Aunty Dan (Remove X from Hotmail to reply directly)


Quote:
> Does anyone know who to retrieve a server side dimensioned array from the
> client side using vbscript?  I basically want to execute some vbscript on
> the onclick() event of a button that recursively reads in data from a
server
> side array.  Any help is appreciated.  Thanks in advance.

> Thuan Tran



Sun, 23 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help converting server-side VBScript array into client-side JScript array

2. How Can I Pass Data Between the Server Side and the Client Side VB/JScript

3. ASP referring to server side variables in client side script

4. Client side and Server side script working together

5. pass server side vbscript to client side javascript

6. how to pass client side values to server side

7. Passing variables from server-side to client-side

8. Passing variables from client-side to server-side

9. Passing Server side vars to Client side

10. Passing a server side var to client side block

11. Passing variable from server side to client side

12. store server-side array in client side

 

 
Powered by phpBB® Forum Software