Forum Moderators: buckworks
I am creating a web based application (ASP, JScript, SQL) that has order placing functionality. I am trying to make a database driven shopping cart to achieve this (first attempt). My problem is I have multiple submit buttons "add to cart" - one per item. Because I am pulling my product id from the database I have set up a loop in which to print my product description, a quantity field, and of course the submit button until the end of the recordset has been reached. I am passing the product id and quantity, then setting up an array to sort those values on the next page, that is fine. However, it will take me over to the next page no matter which "add to cart" button I press. How can I validate this and ensure that my quantity is not 0 for the corresponding button? I need to find a way to uniquely identify each submit button within that loop, so I can successfully validate before passing the information. Any suggestion? Your help is very much appreciated.
Sangarius
1) Warn the customer in the basket page:
if($qty < 1)
{ print "<p>Your quantity of '$qty' is invalid. We have added one into the basket for you</p>"; $qty = 1; }
or 2) Show a completely different page that requests the quantity:
if($qty < 1)
{ &get_quantity_page_sub_routine; exit; }
where the routine get_quantity_page_sub_routine shows a box for them to correct their quantities.
The method I would use would depend on the selling product. If the customer is likely to order more than one of an item I would recommend the second. If most customers will only order one of each line, use option 1 (i.e. correct the error for them).
Thank you,
Sangarius