Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code 2

Status
Not open for further replies.

edd1e19

Programmer
Mar 22, 2004
72
GB
Hi there,

I have a shopping cart, which has three page, one for the products, one for displaying the items chosen, and the other is the checkout. The user selects there item, then it gets added to the page displaying their item and when there are happy with the order they click on proceed to checkout which should the display all their items they have chosen, but i cant get it too work.

I have this code

function updatecart()
{
for (i=0; i<=items.length;i++)
{
if (items.length == 1) items.quantity = parent.cart.document.form1.qty.value;
}
displaycart();
}
function complete()
{
OrdWin=window.open('cart_complete.html','OrdWin');
}


Thanks

edd
 
I don't know why I left the if (items.length == 1) in there. If you remove that part of the code, does it work?

What *specifically* are you finding that doesn't work? You haven't explained what your problem is very well.

Jeff
 
edd1e19,

From a programmer's perspective, if I told you that I had a 3 page web layout, and showed you 2 functions (for a total of about 5 lines of code) and told you it's not working do you think you could fix it?

-kaht

banghead.gif
 
Do you still have the link that i gave you?

thanks

edd
 
i removed this, but did not work. I have been trying to do it for sometime now but still cant get it too work

thanks

edd
 
edd1e19,

If you don't understand why you aren't getting helpful information in your posts, take these things into consideration:

1. When you say "it" doesn't work, we have no clue what "it" is. Try to be as descriptive as possible. We have not been working on your project and don't know what advancements have been made. We don't know what you've got to work, what's been tested, at what point things start to not work, etc....

2. Do not cross post your questions over multiple forums. This is considered extremely bad practice, and it generally ticks people off to see the same question over and over. Most of the people in this forum belong to the other forums that you are crossposting in.

3. Do not create a new post every time you wanna ask a question about the same subject. As you posted above "Do you still have the link that i gave you?". Anybody who hasn't read your previous post obviously hasn't. Instead of us having to take the time to research and go hunt down your previous post, just ask further questions in the same post. This way people don't give you the same suggestions because they can see what answers have been offered already, and seeing someone else's answer might help spark an idea in another person's head. Effectively giving you more options towards a solution.

4. Thank everybody who has been helpful in your posts by awarding them a star. In your bio it shows that you have posted 12 times and not given anybody a star. Stars are a great way to say thanks because it raises the helper's rank in the forum (which is nice if you have a competitive nature like myself).

-kaht

banghead.gif
 
Lets start again.

I am doing a shopping cart using pure javascript, and on the products page there are a list of items. For each item there is a button next to it saying add to cart, when you press this, it updates the shopping cart page, displaying whatever product you chose. These two pages are in the same window being split between 2 frames.

When the user is happy with their selection, they proceed to the checkout by pressing complete order on the shopping cart page, which will then take them to the checkout page, it then should display there items they have chosen, but it doesn't. If you want me to post some code, just ask.

I really do apprecite the help i get here, i just i never knew about those stars.

Thanks

edd
 
Sure... I'm usually lurking somewhere close by (we're in British Summer Time now so maybe an hour earlier than normal).

Your problem is with the popup "checkout" page now, right?

Because your cart is entirely javascript based, once you navigate off the products.html page, you lose the data that combined to make the shopping cart in the first place. You still have the result of building the cart in the left frame of course... and this may be exactly what you intend to do.

You will need to query the left frame and copy the contents into a new array for use on the checkout page.

One suggestion is to put all the javascript into the frameset html document, and call the functions from there. That way at least the original Javascript variables will be preserved in the frameset (less chance of losing that). Then you would be able to query the frameset from the checkout page (window.opener.parent?).

When you say it "doesn't work" what do you mean? What page? Do you get a Javascript error? Have you tried putting alerts throughout the code to pinpoint the exact line things fail on maybe (or the exactly if statement it fails on)?

Kaht... excellent post... can't help but re-iterate that the quality of a question guides the quality and responsiveness of a solution.

Jeff
 
This site is using the same technique I described... in this case the checkout.html page is querying the opener page to get access to the Javascript items array.

Since I modified some of your code for the products page (to provide 0 indexing in the items array) this will probably not work exactly as this page without some customisation.

I have a briefing to go to now... let me know how things are going later on today.

Jeff
 
Few bugz in cart_complete.htm: opener.numitems doesn't exist, javascript arrays begin with 0-index, not 1. Remove line containing numitems and modify for() loop:

Code:
for (i=0; i< opener.items.length; i++) {

Some other tips:

- you are using <input type=image> for completion button. It submits onclick which isn't practical. Cancel this event and remove cart's content later.
- all add/delete images from the right frame are visually identical. Use only two images for all of them and page will load a bit faster.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top