Passing Arrays Between the Browser and an ASP PageBy Luke Bailey
|Passing Arrays from One ASP Page to Another|
|This article demonstrates how to create and use arrays on a client-side form and pass this block of data (the array) to an ASP page when the form is submitted. If you are looking for a solution on passing an array from one ASP page to another be sure to read: Passing Arrays from One ASP Page to Another.|
This library was developed to handle large amounts of data sent by a Shockwave movie and forward it on to an ASP script on a Web server for input to a database. However it could easily be used for other applications such as a "shopping cart" or to deliver a series "slides" in a DHTML page.
This library actually implements a FIFO buffer structure and has the same function calls
can add (
push) and remove (
elements. FIFO Stands for First In First Out which means that
the elements are removed in the same order they were added for example.
To use the library in the browser or in an ASP script you need to include the script as follows:
Before using the library you need to call the initialisation function and, when finished, you should call the finalisation function. These functions can be called as follows:
Once the library is initialised it is ready to be used, you can call the following functions
to add (
push) and remove (
from the buffer:
Other useful functions are the ability to read and write the entire buffer as a string,
empty the buffer, and the ability to count the number of elements that are currently in the
buffer. These are accomplished with the
The functions to read and write the entire buffer can be particularly useful if you need to iterate through the buffer more than once and therefore wish to preserve its state rather than having the elements removed as you read them. For example (in VBScript) you could use the following code to load a buffer from a HTTP POST, iterate through the buffer and print the contents without removing any elements:
You could also write a simple script that writes the buffer into a database table:
Included with the source code is an example application which consists of a simple browser based shopping cart (which uses DHTML) and a sever side ASP script which displays the shopping cart and a total price. This demonstration emulates a multi-dimensional array by adding two elements to the array for each object which is added to the cart (a name and a price).
Notes: Note that the buffer only takes character strings so the use integers or decimals they must first be converted to strings using the built in type conversion features for the relevant library. The buffer also reserves one character to demarcate the elements in the buffer, this character can be chosen in the global variables section in the library file but the currently chosen character cannot be used in any of the strings which are added to the buffer.