Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make VB Array available to JS

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
0
0
AU
Hey everyone,

Is it possible to make an array created with VBscript available as an array in Javascript?

If so, how? I tried accessing it directly with not luck, i.e.

(VBS) astrMyArray(0) = "test"

(JS) astrMyArray[0] returns nothing Steve Davis
hey.you@hahaha.com.au
 
u can use a vbscript variable in javascript only if that vbscript is a part of a server side script. If so then u can use a session variable to store the value in vbscript array and then use the session variable in javascript function again as a server side script.

eg.

vbMyArray(0)="one"
vbMyArray(1)="two"

'now create a session variable to store this array
<% session(&quot;vbArray&quot;) = vbMyarray%>

'Some function in javascript

function someFunctionToAccessVBArray()
{
var jsArray = new Array(<% session(&quot;vbArray&quot;).count %>
jsArray[0] = <%session(&quot;vbArray&quot;)(0)
.
.
.
}

This is a very crude example, but u can only do that if u have a server side script to execute.

Madhavan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top