Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-dimensional session array question

Status
Not open for further replies.

coonbri

IS-IT--Management
May 1, 2008
1
US
I am hoping someone can lend a hand to this issue that I just can't solve. I have a page with several checkboxes which I named the checkbox with all the data that I want to send to subsequent pages. For example, checkbox named "expired1,6000000,fred,smith". I use Split to assign the values to an array. That array needs to make it's way to the next page. I don't know how to do it. Here is my code:

dim rowArray
dim recordArray()
r = 0

For Each Item in Request.Form
If Request.Form(Item).Count Then
For intLoop = 1 to Request.Form(Item).Count
if left(Item,7) = "expired" and Request.Form(Item)(intLoop) = "on" then
rowArray = split(item,",")
redim recordArray(4,r)
recordArray(0,r) = rowArray(0)
recordArray(1,r) = rowArray(1)
recordArray(2,r) = rowArray(2)
recordArray(3,r) = rowArray(3)
'I NEED TO SEND EACH recordArray OVER TO THE NEXT PAGE WHEN IT GETS POSTED. How do I do that?

'This line displays everything just fine. Just need to send this same data in a session variable or ??? to the next page.
response.Write recordArray(0,r) & " " & recordArray(1,r) & " " & recordArray(2,r) & " " & recordArray(3,r) & "<br>"
r = r + 1
end if
Next
End If
Next

Perhaps my approach is all wrong to begin with?

Thank you for any help you can provide!
 
[1] The dimension reflects the ubound() of the array based zero, not reflecting count of entries (based 1) as some other languages.
[2] To redim, you have to use preserve keyword. (And redim only the last dimension that you did it right.)
[3] To pass via session, can just assign the built recordArray to a new session variable, say, session("record").
[tt]
dim rowArray
dim recordArray()
[blue]dim r[/blue]
r = 0

For Each Item in Request.Form
If Request.Form(Item).Count Then
For intLoop = 1 to Request.Form(Item).Count
if left(Item,7) = "expired" and Request.Form(Item)(intLoop) = "on" then
rowArray = split(item,",")
redim [red]preserve[/red] recordArray([red]3[/red],r)
recordArray(0,r) = rowArray(0)
recordArray(1,r) = rowArray(1)
recordArray(2,r) = rowArray(2)
recordArray(3,r) = rowArray(3)
r = r + 1
end if
Next
End If
Next
[blue]session("record")=recordArray
for r=0 to ubound(session("record"),2)
response.Write session("record")(0,r) & " " & session("record")(1,r) & " " & session("record")(2,r) & " " & session("record")(3,r) & "<br>"
next[/blue]
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top