A Shopping Cart Application with JavaScript
By Reaz Hoque
Already a strong contender, e-commerce promises to be a multibillion dollar industry by the year 2000. One success story, of course, is amazon.com, where you can browse through millions of books and place orders online. But amazon.com's resources aren't available to every Joe on the Web. Further, not every Joe needs to create a huge site that will connect to a multidimensional database, or perform credit-card processing against VISA or Mastercard servers. If you have only a few products that you want to sell on the Web, stay tuned. I'll show you how easy it is to create your own online shopping application using JavaScript and a little bit of HTML.
In this article, I'll walk you through the steps required to create a site with a client-side database that can reasonably hold as many as 1000 products. The script uses an array, jigowat, to store product information for each item in the database, and a second array, cart, to store the items checked out for purchase. Once all shopping has been completed, the script provides methods to submit a completed form securely through the Web or email, or by printing out a copy and sending it through conventional mail. Because we'll be using client-side JavaScript, users will be able to browse and shop a lot faster than they would if we used server-side technology.
How It Looks
As an example, we'll study a shopping-cart demo created by Fabric8.c