-
dbMagicCell question
Hello Everyone,
I have aspdb enterprise and it is still pretty new to me. I am trying to create a shopping cart and I ran into a problem. I need to display a textbox on each record that is displayed. That is not a problem anymore. My problem now lies in displaying the text in the textboxes. I have 2 paralell arrays. one stores the product numbers, and the other stores the quantity of the related product. I need to put a different element from the quantity array in each text box that is displayed. If you haven't guessed yet, this is the view cart page. I can specify a value for the text box, but that value is displayed in every text box. That won't work. Is it possible to do this? Am I doing something wrong? Here is my code...
The include files are at the bottom.
***************viewCart.asp*********************** *
<%option explicit%>
<!--#INCLUDE VIRTUAL="/nkatom/includes/array.asp"-->
<!--#INCLUDE VIRTUAL="/nkatom/includes/subs.asp"-->
<!--#INCLUDE VIRTUAL="/nkatom/includes/adovbs.inc"-->
<html>
<head>
<title>View Cart</title>
</head>
<body>
<%
Dim sql
dim MyDb
dim i
dim Quantity
dim q
'EMPTY CART IF REQUESTED
if Request.QueryString("cmd"=1 then
call emptycart(num,qty)
end if
'DISPLAY MESSAGE IF CART IS EMPTY
if session("itemCount"<1 then
Response.Write "<center><h2>Your cart is empty</h2></center>"
else
set myDb=server.CreateObject("aspdb.ep"
myDb.dbDSN="katom"
myDb.dbGridTableTag="border=1 cellpadding=1"
mydb.dbMode="grid"
mydb.dbColor="4,auto"
mydb.dbNavigation="std"
'BUILD THE SQL STATEMENT
sql="SELECT number" & _
", description" & _
", '' as Quantity" & _
", retail" & _
" FROM product" & _
" WHERE number= '" & num(1) & "'"
for i=2 to session("itemCount"
sql=sql & " OR number= '" & num(i) & "'"
next
myDb.dbSQL=sql
MyDb.dbNameMap="number,Product Number;" & _
"description,Description;" & _
"retail,Price;"
'THIS WILL DISPLAY 1 ELEMENT OF THE ARRAY IN THE
'ALL THE TEXT BOXES
MyDb.dbMagicCell = "Quantity,,<center>" & _
"<INPUT TYPE= Text NAME=""#0#"" VALUE=" & _
qty(1) & " SIZE=3></center>;"
myDb.aspDBEP
end if
%>
<p><center>
<a href="sctest.asp"> Continue Shopping</a><br>
<a href="viewcart.asp?cmd=1">Empty Cart</a>
</body>
</html>
*********************end viewCart.asp***************
*********************array.asp******************** **
<%
'INITALIZE LOCAL PRODUCT NUMBER AND QUANTITY ARRAYS
dim pNumArr()
dim qtyArr()
dim itCount
dim num
dim qty
itCount=session("itemCount"
'IF THERE IS SOMETHING IS IN THE CART, THEN
'STORE SESSION VARIBLES LOCALLY
if isArray(session("pNumArr") then
num = session("pNumArr"
qty = session("qtyArr"
end if
%>
***************end array.asp*********************
***************subs.asp**************************
<%
'
'EMPTY SESSION LEVEL ARRAYS
sub emptyCart(num(),qty())
'DELETE ARRAY CONTENTS
for i = lbound(num) to ubound(num)
num(i)=""
qty(i)=""
next
'SET SESSION STUFF
session("itemCount"=0
session("pNumArr" = num
session("qtyArr" = qty
call resize (num,qty)
end sub
'RESIZE ARRAYS
sub resize (num(),qty())
itCount = session("itemCount"
redim preserve num(itcount + 1)
redim preserve qty(itCount + 1)
end sub
%>
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
|
|