Passing an array value to another page

by Nirmala 2009-08-10 16:33:17

Hi...
Use the below code to pass the array values to another asp page.
Example:
Pass the array value from page1.asp to page2.asp. Display array values in page2.asp.
page1.asp
<%
dim I
dim myArray(20)

for I=0 to 20
myArray(I)="Item " & I
next
%>
<html>
<body>
<form name="testform" method="post" action="page2.asp">
<%
for I=0 to ubound(myArray)
Response.Write("<input type=hidden name=myArray value='" & myArray(I) &"'>")
next
%>
<p>
<input type="submit">
</form>
</body>
</html>

page2.asp
<html>
<body>
<%
dim arrString
dim myArray
dim I

arrString=request("myArray")
myArray = split(arrString,",")

for I=0 to ubound(myArray)
response.write "Item "&I&" = " & myArray(I) & "
"
next
%>
</body>
</html>

Tagged in:

1330
like
1
dislike
0
mail
flag

You must LOGIN to add comments