Back to Basics

E

Evertjan.

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()
 
J

Justin Piper

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top