NancyJ
04-12-2005, 04:12 PM
I'm trying to store a global array of productID's and quantities but I'm having problems.
Basically we have a small number of products but not all stored on the same page, the user puts in the number they want then moves on to the next page and I need to be able to store that information until they're done.
This is what I've got so far
-global.asa
<script language="vbscript" runat="server">
sub Session_OnStart
Dim gProducts
Dim gProducts_numRows
Set gProducts = Server.CreateObject("ADODB.Recordset")
gProducts.ActiveConnection = "dsn=Octopus;"
gProducts.Source = "SELECT * FROM Products"
gProducts.CursorType = 0
gProducts.CursorLocation = 2
gProducts.LockType = 1
gProducts.Open()
gProducts_numRows = 0
while not gProducts.eof
gCounter = gCounter+1
gProducts.movenext
wend
gProducts.movefirst
redim gOrder(gCounter, 2)
for i = 0 to gCounter-1
gOrder(i, 0) = gProducts("ID")
gOrder(i, 1) = 0
gProducts.movenext
next
gProducts.movefirst
session("order") = gOrder
session("counter") = gCounter
end sub
Sub Session_OnEnd
gProducts.close()
end sub
</script>
script that stores the info
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
reDim tempOrder(session("counter"), 2)
tempOrder = session("order")
for j = 1 to request.form.count
for each name in request.form
for i = 0 to session("counter")
if tempOrder(i, 0) = name then
tempOrder(i, 1) = request.form(name)
response.write tempOrder(i,0) & ": " & tempOrder(i,1)
end if
next
next
next
session("order") = tempOrder%>
the global.asa seems to be ok but I get a type mismatch on tempOrder = session("order")
Basically we have a small number of products but not all stored on the same page, the user puts in the number they want then moves on to the next page and I need to be able to store that information until they're done.
This is what I've got so far
-global.asa
<script language="vbscript" runat="server">
sub Session_OnStart
Dim gProducts
Dim gProducts_numRows
Set gProducts = Server.CreateObject("ADODB.Recordset")
gProducts.ActiveConnection = "dsn=Octopus;"
gProducts.Source = "SELECT * FROM Products"
gProducts.CursorType = 0
gProducts.CursorLocation = 2
gProducts.LockType = 1
gProducts.Open()
gProducts_numRows = 0
while not gProducts.eof
gCounter = gCounter+1
gProducts.movenext
wend
gProducts.movefirst
redim gOrder(gCounter, 2)
for i = 0 to gCounter-1
gOrder(i, 0) = gProducts("ID")
gOrder(i, 1) = 0
gProducts.movenext
next
gProducts.movefirst
session("order") = gOrder
session("counter") = gCounter
end sub
Sub Session_OnEnd
gProducts.close()
end sub
</script>
script that stores the info
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
reDim tempOrder(session("counter"), 2)
tempOrder = session("order")
for j = 1 to request.form.count
for each name in request.form
for i = 0 to session("counter")
if tempOrder(i, 0) = name then
tempOrder(i, 1) = request.form(name)
response.write tempOrder(i,0) & ": " & tempOrder(i,1)
end if
next
next
next
session("order") = tempOrder%>
the global.asa seems to be ok but I get a type mismatch on tempOrder = session("order")