gi11ies
Programmer
- Mar 26, 2002
- 52
Hi
I am trying to make a simple shopping cart, and am using a 5 element array for each item:
cartArray(0,intCartItem) = strProductName
cartArray(1,intCartItem) = strProductID
cartArray(2,intCartItem) = intProductPrice
cartArray(3,intCartItem) = intProductQuantity
cartArray(4,intCartItem) = intProductPrice * intProductQuantity
When I display the items in the cart, the table I display them in - I am displaying the quantity in a textbox:
<input type="text" name="<% =strQuantity %>" value="<% =cartArray(3,intCartItem) %>" size="4" maxlength="5">
also in the table for the cart, I have put in a checkbox for each item, for removing an item from the cart.
I want to have a button, that when its clicked - it will update the total price for product in the cart by multiplying the quantity by the product price - and also, if the check box for removing a product from the cart is checked, it will remove that product from the cart.
I have managed to create this functionality in ASP.NET, but jave to create it in Classic ASP also, and just can not get my head around t. The ASP.NET code I have used is:
Sub btnUpdate (sender as System.Object, e as System.EventArgs )
objDT = Session("Cart")
Dim dgItem as DataGridItem
Dim chkDel as System.Web.UI.WebControls.CheckBox
Dim i as Integer
For i = dg.Items.Count-1 To 0 Step -1
chkDel = CType(dg.Items(i).FindControl("itemCheck"), CheckBox)
If chkDel.checked then
objDT.Rows(i).Delete()
Else
objDt.Rows(i).Item("Quantity") = CType(dg.Items(i).FindControl("txtQuantity"), TextBox).Text
End If
Next
For Each objDR In objDT.Rows
objDR("Total") = objDR("Quantity") * objDR("Cost")
Next
Session("Cart") = objDT
dg.DataSource = objDT
dg.DataBind()
lblTotal.Text = GetItemTotal().ToString
cartView.visible = true
End Sub
If Anyone has any hints or tips on this, especially on how to remove an item from the array using a check box, it would be great !!!
Gillies
I am trying to make a simple shopping cart, and am using a 5 element array for each item:
cartArray(0,intCartItem) = strProductName
cartArray(1,intCartItem) = strProductID
cartArray(2,intCartItem) = intProductPrice
cartArray(3,intCartItem) = intProductQuantity
cartArray(4,intCartItem) = intProductPrice * intProductQuantity
When I display the items in the cart, the table I display them in - I am displaying the quantity in a textbox:
<input type="text" name="<% =strQuantity %>" value="<% =cartArray(3,intCartItem) %>" size="4" maxlength="5">
also in the table for the cart, I have put in a checkbox for each item, for removing an item from the cart.
I want to have a button, that when its clicked - it will update the total price for product in the cart by multiplying the quantity by the product price - and also, if the check box for removing a product from the cart is checked, it will remove that product from the cart.
I have managed to create this functionality in ASP.NET, but jave to create it in Classic ASP also, and just can not get my head around t. The ASP.NET code I have used is:
Sub btnUpdate (sender as System.Object, e as System.EventArgs )
objDT = Session("Cart")
Dim dgItem as DataGridItem
Dim chkDel as System.Web.UI.WebControls.CheckBox
Dim i as Integer
For i = dg.Items.Count-1 To 0 Step -1
chkDel = CType(dg.Items(i).FindControl("itemCheck"), CheckBox)
If chkDel.checked then
objDT.Rows(i).Delete()
Else
objDt.Rows(i).Item("Quantity") = CType(dg.Items(i).FindControl("txtQuantity"), TextBox).Text
End If
Next
For Each objDR In objDT.Rows
objDR("Total") = objDR("Quantity") * objDR("Cost")
Next
Session("Cart") = objDT
dg.DataSource = objDT
dg.DataBind()
lblTotal.Text = GetItemTotal().ToString
cartView.visible = true
End Sub
If Anyone has any hints or tips on this, especially on how to remove an item from the array using a check box, it would be great !!!
Gillies