Community Forums 

Main Content

Runnint total script

    Jul 15 2012 02:23:15



    Join date : 2008-09-18      Posts : 139

    I am trying to get this running total script to work but the dropdown boxes won't change. The check boxes work fine. but its just the dropdown that won't and I can't figure out what to change to get it working.
    Any help would be greatly appreciated

    Here is the head section of the script

    <script type="text/javascript">
    function UpdateCost() {
    var sum = 0;
    var qty,
    for (i=1; i<5; i++) {
    qty = 'qty'+i;
    prc = 'price'+i;
    (document.getElementById(qty).checked == true)

    sum += Number(document.getElementById(prc).value);
    document.getElementById('totalcost').value = sum.toFixed(2);

    Here is the script for the body section
    <form action=""; method="post" name="CartForm" id="CartForm" onSubmit="UpdateCost()">

    <input type="hidden" name="userid" value="D939432">
    <input type="hidden" name="return" value="">;
    <INPUT TYPE="HIDDEN" NAME="nocart">

    <select name="product1" id="product1" onhange="UpdateCost()">

    <option value="... None :0.00">Please Select</option>
    <option value="... MSI U270 Netbook, :699.00">MSI U270 Netbook $699.00</option>
    <option value="... MSI CR640 i3, :699.00" >MSI CR640 i3 $699.00</option>
    <option value="... MSI CR70, :1194.75">MSI CR70 i5 $1194.75</option>
    <option value="... MSI CX70, :1337.75">MSI CX70 i5 $1337.75</option>
    <option value="... MSI X370 AMD E450, :765.75">MSI X370 AMD E450 $765.75</option>

    <input type="hidden" name="thumb1" value="u270.jpg">
    <input type="hidden" id="qty1" name="qty1" value="1">
    <input type="hidden" id="price1" name="price1" value="">
    Carry Bag $39.95&nbsp;
    <input type="hidden" name="product2" value="Carry Bag">
    <input type="checkbox" id="qty2" name="qty2" value="1" onclick="UpdateCost()">
    <input type="hidden" id="price2" name="price2" value="39.95">

    Nano Wireless Mouse $36.00&nbsp;
    <input type="hidden" name="product3" value="nano Wireless Mouse">
    <input type="checkbox" id="qty3" name="qty3" value="1" onclick="UpdateCost()">
    <input type="hidden" id="price3" name="price3" value="36.00">
    <input type="hidden" name="thumb3" value="nano.jpg">
    2Gb Memory Upgrade $35.00&nbsp;
    <input type="hidden" name="product4" value="2Gb Memory Upgrade">
    <input type="checkbox" id="qty4" name="qty4" value="1" onclick="UpdateCost()">
    <input type="hidden" id="price4" name="price4" value="35.00">

    <strong>Your Total is:</strong>
    <input type="text" id="totalcost" value="" size="5">&nbsp;
    <input type="submit" name="Submit" value="Add To Cart" style="cursor:pointer" onClick="alert('System has been added to your cart\n\nPlease continue to shop or\nClick view cart to checkout.');" >
    <a href="javascript:location.reload(true);">Clear your selection</a>

    Jul 15 2012 04:04:13


    Debbie Q

    Join date : 2008-09-18      Posts : 4998

    Don't have time to test it but 2 things I noticed is shouldn't it be onchange and not onhange? and shouldn't the drop down syntex be productpr1?

    Debbie Q

    Mal's Support:
    GT's Forms and examples:
    Helpful java scripts:
    Shipping help documents:

    My Create-A-Book Publishing -
    Personalized Books, Music CDs and Gifts for all ages and occasions.

    Please help me out and share my site on your networks.

    Jul 15 2012 04:35:25



    Join date : 2008-09-18      Posts : 139

    Hi Debbie,

    I made the changes as necessary but still it only returns 0.00 in the total box when you select from the dropdown. It needs something in the head section I think to get it to work but Im not sure what.

    Jul 15 2012 07:18:32



    Join date : 2008-09-18      Posts : 3235

    I see two errors to do with scripts on your home page:

    In a select box you have:
    select name="productoption"class="selectboxes"
    change it to:
    select name="productoption" class="selectboxes"

    I don't know this syntax name, where did you find it?
    select name="productoption"

    I don't see where you're using my running total script:

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.

    Jul 15 2012 07:32:24



    Join date : 2008-09-18      Posts : 139

    Thanks GT,

    the funny thing with those 2 errors it tells me the > is omitted but when the sites source is viewed they are actually there.

    however the running total1 script from your site is the one that I can't get to work with a select box and it is not on my site yet until I can get it working.

    The one on my site is taken from orderhistory software that is where the productoptions comes from. However due to the lack of support they give I cam looking at your simple version of the running total but stuck on the select box part.

    Once I can get a working version I will dump the other script and use yours. Is there a way to get a select box and also check boxes to work with it.


    Jul 15 2012 09:16:50



    Join date : 2008-09-18      Posts : 3235

    If you need a script building, please email me from my Mal's Forms page.

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.