forum

Home / DeveloperSection / Forums / sum input values and skip one of them jquery

sum input values and skip one of them jquery

Manoj Bhatt221318-May-2013
Hi!

I have form which is making sum of numbers but i want that middle input to be skipped by jquery for summing... please help with this code here i posting... it surely 

must be inupt tag because it sends data to php. i spend so much time to figure this out but i cant like you see.

jQuery

    var total;
    $("input.amount").keyup(function() {
        total = 0;
        $(this).parents("table").find("input.amount").each(function() {
            total += parseInt($(this).val());
        }).end().find("span.total").html(total);
    });
HTML

  <form class="calc">
    Form 1
    <br />
    <table border="0">
        <tr>
            <td>
                Amount 1
            </td>
            <td>
                <input class="amount" type="text" />
            </td>
        </tr>
        <tr>
            <td>
                Amount 2
            </td>
            <td>
                <input class="amount" type="text" />
            </td>
        </tr>
        <tr>
            <td>
                Amount 3
            </td>
            <td>
                <input class="amount" type="text" />
            </td>
        </tr>
        <tr>
            <td>
                Total Amount
            </td>
            <td>
                <span class="total">0</span>
            </td>
        </tr>
    </table>
    </form>

Thanks in advance! 

Updated on 18-May-2013

Can you answer this question?


Answer

1 Answers

Liked By