Classic asp:
sub a
aryaa(0,0)=1
aryaa(0,1)=2
end
how to call this array in script function, and how to make this vbscript array to javascript array.
Please help me out from this, since 3 days i m searching for this.
Thanks.
Classic asp:
sub a
aryaa(0,0)=1
aryaa(0,1)=2
end
how to call this array in script function, and how to make this vbscript array to javascript array.
Please help me out from this, since 3 days i m searching for this.
Thanks.
Suppose MY VBScript array is aryATTPlans than the below code describe ( VBScript array to Javascript array)
// this is client JS code
var aryATTPlans = new Array();
var aryATTPlans = new Array(2);
var i, j;
<%
' this is server VBS code
If IsArray(aryATTPlans) Then
j=0
For i = 0 to ubound(aryATTPlans)
%>
aryATTPlans[<%= i %>] = new Array(2);
aryATTPlans[<%= i %>][<%= j %>] = <%= aryATTPlans(i, j) %>;
<%
Next // i
End If
%>
In Javascript you don't have a native Matrix object type. But you can use either Object or Array such as:
<script type="text/javascript">
var aryaa = [ [1, 2] ];
// aryaa[0][0] = 1
// aryaa[0][1] = 2
</script>
I hope you find this useful. Check MDN documentation anyway.
The following function will convert a multi-dimensional VB safe-array into a multi-dimensional JavaScript array.
function VBtoJSArray(vba) {
var vbarray = new VBArray(vba);
var d = vbarray.dimensions();
var dims = [];
var base = [];
var params = [];
for (var i=1; i <= d; i++) {
dims.push(vbarray.ubound(i)-vbarray.lbound(i) + 1);
base.push(vbarray.lbound(i));
params.push(vbarray.lbound(i));
}
return convertArray(new Array(dims[0]), 0);
function convertArray(ax, index) {
for (var i=0; i < dims[index]; i++) {
params[index] = i + base[index];
if (index == dims.length-1) {
ax[i] = VBArray.prototype.getItem.apply(vbarray, params);
}
else {
ax[i] = new Array(dims[index+1]);
convertArray(ax[i], index+1);
}
}
return ax;
}
}