• Notice regarding image hosts and attachments. See here.

Shopping Basket - help

Soldato
Joined
8 Oct 2007
Posts
2,844
Hi, I'm trying to make a shopping basket on a web page.

So far I've got a HTML page with the items, a quantity drop down menu (0-9), a 'Add to Basket' button next to each item and a 'View Shopping Basket' button at the bottom of the page.

What I need help with is the next part, I need to make a javascript function that generates a table. Which displays the items in the basket, the name of the item, quantity the price and the sum (quantity*price) And then a total price of all the items.

Also the Add to Basket button, and how to store the data about the basket (ie how many of each item are in the basket) I don't know what to do about that.

Any help appriciated :)
 
I'm afraid trying to do what you want purely client side is going to be difficult. You'll either want a server-side solution or to use something like PayPal shopping cart. How are you going to fulfill orders for instance? How is that data going to be saved?
 
Hmm what you want to do is not easy. As far as getting the data back server side, are you planning to implement a GET/POST function with this? Will it be after the user has selected the quantity and hits 'next' or whatever?

A better approach might be to use some AJAX to POST the data each time a change is made, and have a PHP script echo the data back to your page as a table or whatever (with no refresh), hence everything is kept server- side and makes the whole thing easier to manage.
 
You really need all of the application logic on the server side otherwise it can be easily spoofed. If your setting the price on the client side there is nothing to stop anyone sending something different. As mentioned above, you can use AJAX to display the data on the clientside but you want to check it with the server first.
 
Back
Top Bottom