Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Changing Javascript Variable with Form

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26594
    Artellectual
    Participant

    Hey Guys,

    I’ve been working on a little something :)

    I’ve been trying to use this shopping cart called simpleCart(js) its a javascript based shopping cart and I am stuck on just 1 thing. the shipping!

    Anyway the variable that controls the flatrate shipping for the cart is

    simpleCart.shippingFlatRate

    however I want the user to have a choice, to choose what shipping they want. so here is my code for the form.

    Code:

    I set it that when the user chooses an option it updates the variable and that is then passed into the flat shipping variable on the simpleCart(js) script however when I do this it always detect teh shipping as 0.00

    Please help me out! Any help will be greatly appreciated.

    Thank You

    #66043
    Artellectual
    Participant

    its ok guys I figured it out :)

    #69756
    jhonqwerty
    Member

    so, how did you figured it out?
    I’m stuck in the same part…

    Any hint would be appreciated.

    #70003
    jhonqwerty
    Member

    So the solution for me was really simple, you have to add at the end of the onchange script the Simplecart function: simpleCart.update();

    here is the script I made with lots of cut and paste from other places:

    Code:
    window.onload = initForm;
    function initForm(){
    document.getElementById(“shippingChoice”).selectedIndex = 0;
    document.getElementById(“shippingChoice”).onchange = populateApplication;
    }

    function populateApplication(){
    var edNum = document.getElementById(“shippingChoice”).selectedIndex;
    var edValue = document.getElementById(“shippingChoice”).options[edNum].value;
    simpleCart.shippingFlatRate = edValue;
    simpleCart.update();
    }

    And here is the HTML:

    Code:

    And the Paypal order worked fine…

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.