|
-
Apr 21st, 2001, 03:56 PM
#1
Thread Starter
Hyperactive Member
Hello,
How can I pass an array from one page to the next.
Eg.
In page 1 I have
<%
dim array1(100)
array1(1) = "hello"
array1(2) = "word"
%>
I now submit/post this form to page2 where I want to do something like
<%
dim array2(100)
array2 = request.form array1
response.write array2(1)
response.write array2(2)
%>
Which must results in - "helloworld".
Can it be done.
Thanks,
T
-
Apr 21st, 2001, 05:34 PM
#2
Junior Member
You will need to pass the values to the next page us a FORM or by putting the values in the QueryString. Just assign the values in your form to have the same name.
Example:
Code:
<form action="page2.asp" method="get">
<%
dim array1(100)
array1(1) = "hello"
array1(2) = "word"
For i = LBound(array1) to UBound(array1)
%>
<input type="hidden" name="array1" value="<%=array(i)%>">
<%
Next
%>
</form>
page2.asp should have the following code
Code:
<%
dim array1(100)
For i = 1 to Request.QueryString("array1").Count
array(i - 1) = Request.QueryString("array1")(i)
Next
%>
This should take care of it, for an array of pre determined size. If the array is dynamic you will need to ReDim it accordingly.
Also remember that VBScript arrays are zero based by default.
-
Apr 22nd, 2001, 04:35 AM
#3
Thread Starter
Hyperactive Member
Thanks kkolstad,
It works great!!
T
-
Apr 22nd, 2001, 02:17 PM
#4
Addicted Member
Another option will be push store the array in a session or application wide variable.
-
Sep 12th, 2001, 10:04 AM
#5
PowerPoster
yep works real well I did this
Code:
<%for p = 0 to ubound(strSt)%>
<input type="hidden" name="ArrayState" value="<%=strSt(p)%>">
<%next%>
<%for d = 0 to ubound(strSt)%>
<input type="hidden" name="ArrayTotal" value="<%=strTl(d)%>">
<%next%>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|