Community Forums 

Main Content

Items not selected are added to cart as 0.00

    Nov 24 2008 07:00:48



    Join date : 2008-09-18      Posts : 137

    With this code below if you just select 1 item from the list and then click on Order it puts everything in the cart is there a way to have it only take over the items that are selected instead of everything.

    <script language="JavaScript" type="text/javascript">
    function UpdateCost() {
    var sum = 0;
    var gn, elem;
    for (i=1; i<11; i++) {
    gn = 'product'+i;
    elem = document.getElementById(gn);
    if (elem.checked == true) { sum += Number(elem.value); }
    document.getElementById('total').value = sum.toFixed(2);

    <form action=""; method="post">
    <input type="hidden" name="userid" value="D939432">
    <input type="hidden" name="return" value="">;

    <input type="checkbox" name="price1" id="product1" value="9.99" onClick="UpdateCost()">Product 1 (9.99)<br>
    <input type="hidden" name="qty1" value="1"><input type="hidden" name="product1" value="Product 1">
    <input type="checkbox" name="price2" id="product2" value="19.99" onClick="UpdateCost()">Product 2 (19.99)<br>
    <input type="hidden" name="qty2" value="1"><input type="hidden" name="product2" value="Product 2">
    <input type="checkbox" name="price3" id="product3" value="24.99" onClick="UpdateCost()">Product 3 (24.99)<br>
    <input type="hidden" name="qty3" value="1"><input type="hidden" name="product3" value="Product 3">
    <input type="checkbox" name="price4" id="product4" value="29.99" onClick="UpdateCost()">Product 4 (29.99)<br>
    <input type="hidden" name="qty4" value="1"><input type="hidden" name="product4" value="Product 4">
    <input type="checkbox" name="price5" id="product5" value="39.99" onClick="UpdateCost()">Product 5 (39.99)<br>
    <input type="hidden" name="qty5" value="1"><input type="hidden" name="product5" value="Product 5">
    <input type="checkbox" name="price6" id="product6" value="49.99" onClick="UpdateCost()">Product 6 (49.99)<br>
    <input type="hidden" name="qty6" value="1"><input type="hidden" name="product6" value="Product 6">
    <input type="checkbox" name="price7" id="product7" value="59.99" onClick="UpdateCost()">Product 7 (59.99)<br>
    <input type="hidden" name="qty7" value="1"><input type="hidden" name="product7" value="Product 7">
    <input type="checkbox" name="price8" id="product8" value="69.99" onClick="UpdateCost()">Product 8 (69.99)<br>
    <input type="hidden" name="qty8" value="1"><input type="hidden" name="product8" value="Product 8">
    <input type="checkbox" name="price9" id="product9" value="79.99" onClick="UpdateCost()">Product 9 (79.99)<br>
    <input type="hidden" name="qty9" value="1"><input type="hidden" name="product9" value="Product 9">
    <input type="checkbox" name="price10" id="product10" value="89.99" onClick="UpdateCost()">Product 10 (89.99)<br>
    <input type="hidden" name="qty10" value="1"><input type="hidden" name="product10" value="Product 10">

    <input type="text" id="total" value="">
    <input type="submit" value="Order!">

    Nov 24 2008 07:39:05


    just visiting

    Join date : 2008-09-18      Posts : 2973

    Maybe use the checkbox for the qty.

    Some shipping help documents are available at