How can I get a variable from a declared array in an ASP page?

Syringer

Lifer
Aug 2, 2001
19,333
2
71
So I have a site that's a storefront (via volusion.com), and in order to track orders I have to pass certain variables through to a 3rd party site via javascript.

The vars are stored in an array that's automatically generated and declared, and I have to pull the vars from them.

Here are the variables that are automatically generated via the array

OrderDetails[0] = new Array();
OrderDetails[0][0] = '3073'; // OrderID
OrderDetails[0][6] = '1'; // Quantity

So now basically below that I have a javascript that I want to transfer the array vars into the below:

var orderID = 'OrderDetails[0][0]';
var quantity = 'OrderDetails[0][6]';


so that my orderID = 3073, and quantity = 1.

What would be the proper format for those bolded lines in this .asp page to get the vars over?

I know in .asp for normal vars I would just do something like:

var quantity = '$(Quan)'--if "Quan" existed.

But it appears that it's different for arrays..since I've tried

var quantity ='$(OrderDetails)[0][6]';

and

var quantity ='$(OrderDetails[0][6])';

to no avail.

Any help would be great :)
 

clamum

Lifer
Feb 13, 2003
26,256
406
126
You want to access the values held in these JavaScript variables in ASP code?

I would probably either put them in hidden fields and grab the hidden fields' values from ASP:

HTML:
<input type="hidden" id="_hiddenOrderID" />
<input type="hidden" id="_hiddenQuantity" />

JavaScript:
document.getElementById('_hiddenOrderID').value = orderID;
document.getElementById('_hiddenQuantity').value = quantity;

ASP:
I forget the syntax, someone else can help you here. I only know ASP.NET syntax.

-----

or if it's possible, send them in a QueryString: Somepage.asp?orderID=3070&quantity=1

Then use ASP to grab the values:

Dim orderID;
orderID = Request.QueryString("orderID");
Dim quantity;
quantity = Request.QueryString("quantity");