
Session variables and Arrays
Hi people,
I've been on this little piece of code all day, and I can't find out why it
doesn't work.
(IIS 3, ASP1)
Here's the code:
----------------------------------------------------------------------------
---
dim iStep
dim iNextStep
dim oForm
If Request.ServerVariables( "REQUEST_METHOD" ) = "POST" Then
Set oForm = Request.Form
Else
Set oForm = Request.QueryString
End If
' aNextStep( ) array defined on beforehand (not included -> works fine)
iStep = oForm( "step" )
iNextStep = aNextStep( iStep )
' Everything works until here.
Session( "formvars" ) = Array( "_dummy" )
Dim sItem
Dim aTemp
For Each sItem In oForm
If LCase( Left( sItem, 1 ) ) = "q" Then
aTemp = Session( "formvars" )
' The next line fails: Type mismatch.
aTemp( sItem ) = oForm( sItem )
Session( "formvars" ) = aTemp
End If
Next
----------------------------------------------------------------------------
-------
I've tried several approaches.
I used Request.Querystring or Request.Form directly instead of the oForm
construct. Same problem.
I tried with a temporary array (like in the code above) or without one. Same
problem.
Even doing:
Session( "formvars" )( "dummy ") = "dummy" gives a type mismatch.
Can't i have arrays in Session variables?
What I want is this:
There are several forms following each other, each asking the user some
questions. I want every answer to be recorded in the Session so that I can
calculate a score at the end. I could go iterating over each specific value
but I want to do it automatically: each variable that begins with 'q' should
be processed at the end.
Storing the 'qX' values directly into the Session works, but how can i get
them back out? This code doesn't do it:
----------------------------------------------------------------------------
-------
Dim iScore
iScore = 0
For Each sItem In Session
Response.Write "sItem=" & sItem & "<BR>"
Next
----------------------------------------------------------------------------
-------
ASP1 doesn't seem to know about Session.Contents, so that's to no avail
either.
*sigh*
any help?
Tom.
(Does anyone know a good resource about ASP 1 on IIS 3?)