shopping cart problem

Discussion in 'Javascript' started by fiona, May 26, 2006.

  1. fiona

    fiona Guest

    Be grateful if someone could help me out with this.
    I'm working on a shopping cart where I want the choice of adding four
    different items to it
    What's happining at the moment is when I add something from the top box
    named productid id it adds the item to the cookie.
    when I try to add something from any other "productid" it still adds
    the
    first item quantity to the cart
    Now, I imagine this is because I have the variables all named the
    same, but
    I don't know how to change it do i add in
    four variables in place of the "id" variable now?

    Thanks for any help



    function setCookie1()
    {
    alert("Setting the cookie");
    alert("Quantity:"+document.purchaseForm.priceText.value);
    // var id = prompt("What's your product ID?","");

    //var qty = prompt("What's the quantity?", "");

    id = document.purchaseForm.productId.value;
    qty = document.purchaseForm.priceText.value;
    var previousCookie= document.cookie; //retrieve cookies held

    var previousData = unescape(previousCookie);

    var newData = id +":" + qty;
    newData = newData+"/"+previousData;

    var cookie1 = escape(newData);

    document.cookie = cookie1;

    }
     
    fiona, May 26, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GeorgeF

    Perl Shopping Cart Scripts

    GeorgeF, May 21, 2005, in forum: Perl
    Replies:
    1
    Views:
    3,263
    James T
    May 22, 2005
  2. =?Utf-8?B?Q2hpV2hpdGVTb3g=?=

    shopping cart problem

    =?Utf-8?B?Q2hpV2hpdGVTb3g=?=, Jan 29, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    379
    Mark Rae
    Jan 29, 2007
  3. Randi

    simple shopping cart problem

    Randi, Apr 2, 2004, in forum: Javascript
    Replies:
    3
    Views:
    123
    Michael Winter
    Apr 2, 2004
  4. Randi

    Help with shopping cart problem

    Randi, Apr 3, 2004, in forum: Javascript
    Replies:
    1
    Views:
    93
    Michael Winter
    Apr 3, 2004
  5. Phil McKraken

    Help ! Shopping Cart Problem

    Phil McKraken, Oct 29, 2005, in forum: Javascript
    Replies:
    17
    Views:
    188
    Dr John Stockton
    Nov 2, 2005
Loading...

Share This Page