Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-03-2010, 01:45 AM   PM User | #1
lostcause!
New to the CF scene

 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
lostcause! is an unknown quantity at this point
Unhappy Javascript Trouble with Shopping cart function

Hi all,

Like many here, i am a novice. i have read alot and gone through tutorials and actually have a good grasp of how functions, arrays, DOM and so on work.
But i just can't put all the elements i have learn't together to create my shopping cart site.

I’ll give you an over view of what I have to do, then what’s trouble me:

• Display of a few toys on a single web page with their name, image and price and a drop down menu to allow the user to select a desired quantity of each toy.

• Add to Shopping Cart – A button (“Add to Cart”) should appear either next to each toy or one for the entire page so that when clicked the desired quantity of each toy can be added to the shopping cart, by executing the appropriate event handler method and invoking the Javascript function AddToCart().

• AddToCart() function should do the following: i) Store the name of each toy, quantity and sum (calculated by quantity*price) in three global arrays name[],quantity[] and sum[].

• A “view shopping cart” button should also appear on the page so that when clicked the appropriate event handler method is executed which will invoke the Javascript function ViewShoppingCart(). The ViewShoppingCart() function should display the the contents of the user’s shopping cart in the form of a dynamically generated table. Each row of the table should display the name of the toy, the quantity, the price and the sum (quantity*price) which is present in the shopping cart. Finally the total price of all toys in the shopping cart should be displayed at the end of the table.

• The ViewCart() function should do the following i) Iterate (loop) through the three arrays name[],price[] and sum[] and display the elements of the three arrays in the cells of a dynamically generated table. The total sum of the shopping cart should also be displayed somewhere at the end of the table.

I would really appriciate some pointers on how to tackle this problem.

Thankyou in advanced

Matt
lostcause! is offline   Reply With Quote
Old 05-04-2010, 03:00 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
First at all you need a database, a relational database management system (RDBMS) to handle that DB, a sever language which will make queries to that DB.

Probably the easier (mainly because it is freeware) is to use Apache as server, MySQL as DB / DB management system, and PHP as the server-side language. PHP/MySQL, by short.

The JavaScript toys are rather irrelevant in this equation. Maybe if you need an asynchronous query, in which case you may use AJAX as technique.

Do you know all these? If not, it is time to learn them. Or to hire a professional.

After learning at least the basis of those languages/RDBMS, you may shorten the implementation time on using a framework. For PHP/MySQL you may use templates created in Drupal. Or in Joomla. Google for.

Of course, you must know also (at east at average level) HTML/XHTML, CSS, Javascript and, probably XML.

It is hard for a single inexperienced beginner. Usually this kind of product (e-commerce site) is to be done in a team. At least 2 people: 1 designer& client-side programmer (Photoshop, HTML, CSS, JavaScript, AJAX) and 1 server-side admin and programmer (Apache/PHP/MySQL).
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 05-04-2010 at 03:15 PM..
Kor is offline   Reply With Quote
Old 03-18-2011, 02:56 PM   PM User | #3
chicawapa
New to the CF scene

 
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
chicawapa is an unknown quantity at this point
Can anyone provide the code for the Shopping cart function and view cart function? I'm a novice and would like to have an idea of it as I'm doing something similar.

Or pointers on code, etc, anything would help!

Thanks!
chicawapa is offline   Reply With Quote
Old 03-18-2011, 03:04 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Quote:
Originally Posted by chicawapa View Post
Can anyone provide the code for the Shopping cart function and view cart function? I'm a novice and would like to have an idea of it as I'm doing something similar.

Or pointers on code, etc, anything would help!

Thanks!
Hm. How can you start creating a a Shopping cart without basic knowledge. Do you think that there is an "Universal Code for Shopping Cart", or similar, which you can simply stick to a site?

A shopping cart is a multi-language application - an inter-relational relationship between a server data base, a server-side language and client-side languages.

What kind of DB do you have? What server-side languages runs on your server? Do you know those languages? Have you read my previous post?
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 03-18-2011 at 03:07 PM..
Kor is offline   Reply With Quote
Reply

Bookmarks

Tags
arrays, dynamic, javascript, shopping cart, table

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:13 AM.


Advertisement
Log in to turn off these ads.