hi everyone. i'm trying to make a (very) simple shopping cart for my class. i'm stuck on the qty update - it says it's not defined. i think it may have something to do with when i check to see if the form has been submitted yet or not. any help would totally rock!
todrik
here's the first page (which works fine)
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtm">
<head>
<title> Todd Infinger Final Exam </title>
</head>
<body>
<font size = "+2" color = "Blue"><center>Welcome to Todd's Store!</font><br/><br/>
<font color = "blue">Here is our product list:</font><br/>
<cfquery name = "toddsproducts" datasource = "tri1_scartwpics2">
select [Products.ProductID], [Products.ProductName], [Products.ProductQty], [Products.ProductPrice], [Suppliers.SupplierName], [Products.ProductPhoto]
from Suppliers inner join Products on [Suppliers].[SupplierID] = [Products].[SupplierID]
</cfquery>
<table border = "1" cellspacing = "0">
<tr>
<td width = "10%" bordercolor = "red"><b><center>Product ID</center></b></td>
<td width = "15%" bordercolor = "red"><b><center>Product Name</center></b></td>
<td width = "10%" bordercolor = "red"><b><center>Product Quantity</center></b></td>
<td width = "10%" bordercolor = "red"><b><center>Product Price</center></b></td>
<td width = "15%" bordercolor = "red"><b><center>Brand</center></b></td>
<td width = "15%" bordercolor = "red"><b><center>Product Photo</center></b></td>
<td width = "10%" bordercolor = "red"><b><center>Buy</center></b></td>
</tr>
<cfoutput query = "toddsproducts">
<tr>
<td width = "10%" bordercolor = "red"><center>#toddsproducts.ProductID#</center></td>
<td width = "15%" bordercolor = "red"><center>#toddsproducts.ProductName#</center></td>
<td width = "10%" bordercolor = "red"><center>#toddsproducts.ProductQty#</center></td>
<td width = "10%" bordercolor = "red"><center>#NumberFormat(toddsproducts.ProductPrice, "$_,___.__")#</center></td>
<td width = "15%" bordercolor = "red"><center>#toddsproducts.SupplierName#</td>
<td width = "15%" bordercolor = "red"><center><img width = "120" height = "120" src = #toddsproducts.ProductPhoto#></img></center></td>
<td width = "10%" bordercolor = "red">
<cfif toddsproducts.productqty gt 0>
<a href="shoppingcart.cfm?productid=#toddsproducts.productid#&productname=#toddsproducts.productname#&brand=#toddsproducts.suppliername#&price=#toddsproducts.productprice#&qty=1&qtyAvail=#toddsproducts.ProductQty#"><center>Add to Cart</center></a>
<cfelse>
<center>Out of stock!</center>
</cfif>
</center>
</tr>
</cfoutput>
</table></center>
</body>
</html>
and here's the second i'm struggling with
<font size="+2" color="magenta"><center>Your shopping cart<center></font><br><br>
<cfset session.productid= url.ProductID>
<cfset session.productname= url.ProductName>
<cfset session.productprice= url.Price>
<cfif NOT isDefined("form.submit")>AND NOT IsDefined("Form.Update")>
<cfset session.qty = 1>
<cfset ItemTotal = (session.productprice * session.qty)>
<cfset OrderTotal = ItemTotal>
<cfset Tax = OrderTotal * 0.07>
<cfset TotalOrderAmount = OrderTotal + Tax>
<cfelse>
<cfset session.qty = url.qty>
<cfset ItemTotal = (session.productprice * session.qty)>
<cfset OrderTotal = ItemTotal>
<cfset Tax = OrderTotal * 0.07>
<cfset TotalOrderAmount = OrderTotal + Tax>
</cfif>
<center>
<table border = "1" cellspacing = "0" bordercolor="red">
<tr>
<td bgcolor="pink"><b><font color="magenta">Product Code</font></b></td>
<td bgcolor="pink"><b><font color="magenta">Product Name</font></b></td>
<td bgcolor="pink"><b><font color="magenta">Unit Price</font></b></td>
<td bgcolor="pink"><b><font color="magenta">Quantity Ordered</font></b></td>
<td bgcolor="pink"><b><font color="magenta">Total Cost</font></b></td>
</tr>
<tr>
<td height="43"><cfoutput>#session.productid#</cfoutput></td>
<td><cfoutput>#session.productname#</cfoutput></td>
<td><cfoutput>#DollarFormat(session.productprice)#</cfoutput></td>
<td>
<cfform action="shoppingcart.cfm?productid=#session.productid#&productname=#session.productname#&price=#session.productprice#&qty=#form.newqty#" method="submit">
<input type="text" size = "5" name="newqty">
<input type="submit" value="Update" >
</cfform>
</td>
<td align="right"><cfoutput>#DollarFormat(ItemTotal)#</cfoutput></td>
</tr>
<tr><td colspan=4 align="left">Total</td>
<td align=right><cfoutput>#DollarFormat(OrderTotal)#</cfoutput></td>
</tr>
<tr>
<td colspan=4 align="left">Tax (7%)</td>
<td align=right><cfoutput>#DollarFormat(Tax)#</cfoutput></td>
</tr>
<tr>
<td colspan=4 align="left">Total Order Amount</td>
<td align=right><cfoutput>#DollarFormat(TotalOrderAmount)#</cfoutput></td>
</tr>
</table></center>
<br>
</body>
</html>