?Passing arrays from Server script to Client Script 
Author Message
 ?Passing arrays from Server script to Client Script

Why is it that I can pass single variables from Server script to Client
script, but I can't pass arrays?  Is special way of handling this
requirement?  I have a Session object  that contains an array that was
initialized prior to coming into the new page.  From this new page I want to
have access to this Session Object (containing the array) available to the
client script.  Depending upon input from the user, I want to make certain
values available to display from this array.

Thanks,
Gary



Sat, 28 Apr 2001 03:00:00 GMT  
 ?Passing arrays from Server script to Client Script
<script>
var myArray = new Array();

<% for i = 0 to ubound(serverArray) %>
myArray(<%=i%>) = "<%=serverArray(i)%>";
<% next %>
numElements = <%=ubound(serverArray)%>

</script>

Of course if your array is made up of integers you don't use the quotes.

   ______
   ab/mvp


Quote:
>Why is it that I can pass single variables from Server script to Client
>script, but I can't pass arrays?  Is special way of handling this
>requirement?  I have a Session object  that contains an array that was
>initialized prior to coming into the new page.  From this new page I want
to
>have access to this Session Object (containing the array) available to the
>client script.  Depending upon input from the user, I want to make certain
>values available to display from this array.



Sat, 28 Apr 2001 03:00:00 GMT  
 ?Passing arrays from Server script to Client Script
Aaron,

  I'll give your suggestion a try.  Thanks for the quick response.

Gary



Sat, 28 Apr 2001 03:00:00 GMT  
 ?Passing arrays from Server script to Client Script
Aaron,

  The solution did not work.  Here is my version, which is in JavaScript.

<%SrvrBalArray = Session("Balances");%>
var localBalArray = new Array();
<% for (i = 0; i < SrvrBalArray.length; i++) {%>
localBalArray(<%=i%>) = <%=SrvrBalArray[i]%>;
<% } %>
numElements = localBalArray.length;
</script>



Sat, 28 Apr 2001 03:00:00 GMT  
 ?Passing arrays from Server script to Client Script

Quote:
>  The solution did not work.  Here is my version, which is in JavaScript.

What does "did not work" mean? Unless it's because of the typo I had here,
it may have caused your problem:

Quote:
>localBalArray(<%=i%>) = <%=SrvrBalArray[i]%>;

Should be brackets instead of parentheses:

localBalArray[<%=i%>] = <%=SrvrBalArray[i]%>;

My mind is fluent in VBScript but only conversational in JScript.  :)

   ______
   ab/mvp



Sat, 28 Apr 2001 03:00:00 GMT  
 ?Passing arrays from Server script to Client Script
Aaron,

   As it turns out, I put the test script in a page that had not yet caused
the Session object (server array)  to be initialized.

Thanks again,
Gary



Sat, 28 Apr 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ?Passing arrays from Server script to Client Script

2. Passing Server Side Arrays to Client Side Scripts

3. Passing value from Server script to client script.

4. questions on passing text parameter from server script to client script (some new findings)

5. questions on passing parameter from server script to client script

6. Pass client script variable to server script variable

7. Help: problem passing variable between client/server scripts

8. Passing values from client vars to Server script

9. Urgent : Passing variables from client script to server side

10. Help: problem passing variable between client/server scripts

11. How to Send Server Array to Client Script

12. Passing Server Array to Client JScript

 

 
Powered by phpBB® Forum Software