Passing Server Array to Client JScript 
Author Message
 Passing Server Array to Client JScript

I'm having problems passing an entire VBScript server side array to client
side JavaScript.  The error I receive is as follows:
Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range
/test.asp, line 36

See my test code below:


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<% Dim strMyServerVar(2)
strMyServerVar(0) = "42"
strMyServerVar(1) = "43"
%>
The following line of HTML was generated on the server using server
scripting to print the value of a server variable into the page before the
page was sent to the browser:
<br>
<br>
<strong>
The value of the server variable(0) is <%=strMyServerVar(0)%>.
<BR>
The value of the server variable(1) is <%=strMyServerVar(1)%>.
</strong>
<br>
<br>
The following line of HTML was generated on the client to print the value of
a client variable into the page after the page was sent to the browser. The
value of the client variable has been set equal to the value of the server
variable printed above.
<BR>
<BR>
<SCRIPT LANGUAGE = "JavaScript">
<!---
var x ;
var y ;
var z = new Array();

x = <%= strMyServerVar(0) %> ;
y = <%= strMyServerVar(1) %> ;
z = <%= strMyServerVar() %> ;
if (x == <%= strMyServerVar(0)%>) {
   document.write ("<STRONG>The value of the client variable is " + x +
".</STRONG><BR>")
   }
if (y == <%= strMyServerVar(1)%>) {
   document.write ("<STRONG>The value of the client variable is " + y +
".</STRONG><BR>")
   }
if (z(0) == <%= strMyServerVar(0)%>) {
   document.write ("<STRONG>The value of the client variable is " + z(0) +
".</STRONG><BR>")
   }
if (z(1) == <%= strMyServerVar(1)%>) {
   document.write ("<STRONG>The value of the client variable is " + z(1) +
".</STRONG><BR>")
   }
//
--->
</SCRIPT>



Sat, 16 Aug 2003 05:11:18 GMT  
 Passing Server Array to Client JScript
Asked and answered in ...scripting.vbscript

(PS - please check your newsreader's help on how to post one message to more than one group,
commonly referred to as crossposting.)

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> I'm having problems passing an entire VBScript server side array to client
> side JavaScript.  The error I receive is as follows:
> Error Type:
> Microsoft VBScript runtime (0x800A0009)
> Subscript out of range
> /test.asp, line 36

> See my test code below:


> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
> <TITLE>Document Title</TITLE>
> </HEAD>
> <BODY>
> <% Dim strMyServerVar(2)
> strMyServerVar(0) = "42"
> strMyServerVar(1) = "43"
> %>
> The following line of HTML was generated on the server using server
> scripting to print the value of a server variable into the page before the
> page was sent to the browser:
> <br>
> <br>
> <strong>
> The value of the server variable(0) is <%=strMyServerVar(0)%>.
> <BR>
> The value of the server variable(1) is <%=strMyServerVar(1)%>.
> </strong>
> <br>
> <br>
> The following line of HTML was generated on the client to print the value of
> a client variable into the page after the page was sent to the browser. The
> value of the client variable has been set equal to the value of the server
> variable printed above.
> <BR>
> <BR>
> <SCRIPT LANGUAGE = "JavaScript">
> <!---
> var x ;
> var y ;
> var z = new Array();

> x = <%= strMyServerVar(0) %> ;
> y = <%= strMyServerVar(1) %> ;
> z = <%= strMyServerVar() %> ;
> if (x == <%= strMyServerVar(0)%>) {
>    document.write ("<STRONG>The value of the client variable is " + x +
> ".</STRONG><BR>")
>    }
> if (y == <%= strMyServerVar(1)%>) {
>    document.write ("<STRONG>The value of the client variable is " + y +
> ".</STRONG><BR>")
>    }
> if (z(0) == <%= strMyServerVar(0)%>) {
>    document.write ("<STRONG>The value of the client variable is " + z(0) +
> ".</STRONG><BR>")
>    }
> if (z(1) == <%= strMyServerVar(1)%>) {
>    document.write ("<STRONG>The value of the client variable is " + z(1) +
> ".</STRONG><BR>")
>    }
> //
> --->
> </SCRIPT>



Sun, 17 Aug 2003 12:14:17 GMT  
 
 [ 2 post ] 

 Relevant Pages 

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

2. Passing an Array from the Server to the Client

3. ?Passing arrays from Server script to Client Script

4. Passing array from COM server to VBScript client

5. Passing Server Side Arrays to Client Side Scripts

6. Passing an array from client to server.

7. ?Passing arrays from Server script to Client Script

8. Passing arrays to COM java objects from JScript (Server Side)

9. Passing Array from JScript to COM Server

10. Passing Array from JScript to COM Server

11. passing jscript arrays TO Automation servers

12. getting server side vbscript array to client side jscript

 

 
Powered by phpBB® Forum Software