Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Passing an array to an active server page

Is it possible to pass an array to an active server page, using
the post method, as in
URL?array=array_name(5)&size_of_array=5

or in some simialr way.
I have to pass about 20 values to the asp.
      If it is not possible to pass an array would
it be O.K. to pass them as single arguments, i.e.
having 20 vaules listed after the URL.
      Is there any other way to achieve this goal.
Thanks in advance
0
martythegreat
Asked:
martythegreat
1 Solution
 
mitekCommented:
Of course, it's possible. The specs were designed in such a way so that to allow passing multiple arguments with the same name via GET or POST methods.

The idea is to do something like:

script.asp?array_name=5&array_name=8&array_name=some_text&array_name=abc&other_array=5&other_array=10 ... etc.

and the like. If there are duplicate names in the get (post data) string, they will be treated as an array. This way one can pass several arrays to an asp script.

The good news is that it keeps the order of values, too ! In one application, I actually was passing two arrays of values (along with several standalone vars) using the method described above -- one array of value ids, and the other one -- of values (to be inserted into a database). And they ALWAYS matched -- meaning, they translated into array exactly in the order they apperad in GET (POST) string

In ASP, if it's VBScript, just treat the
Request.Query("array_name") as an array.

Of course, it's possible also to pass array in single variable, following certain naming convention, if you know in advance how many values you'll have. Like,
script.asp?array_name1=5&array_name2=8&array_name3=some_text&array_name4=abc&other_array1=5&other_array2=10 ...

but it's much more limiting -- using the first method, you don't need to know the array size.
 
BTW, POST and GET methods use pretty much the same conventions about passing arguments.









0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now