Koala7
Koala7

Reputation: 1404

Getting selected option change jquery

I have a table editable with an Invoice calculator. I have a small issue in my select editable. If you click on IVA 21 % you notice that you can select the option IVA none, i need that once i selected the option none in my select editable, it does not automatically calculate my IVA. I do not how to manage it, or setting an on change jQuery or a submit, in both cases i was not able to do it!.

The calculator works, if you select no Iva and then you clone a row clicking on +, the IVA is not calculated but i want to achieve it the same once i select the option NO IVA.

This the code :

if ($('.editable_selectiva').text() === "NO IVA") {
            $('#total').html(0);
            $('#total1').html(total);
        }
        else {
            $('#total').html(total*0.21);
            $('#total1').html(total*1.21);
        }
    })
}

Hope the explanation is clear and you can help me out. Thanks

Upvotes: 0

Views: 224

Answers (2)

Shahid
Shahid

Reputation: 666

Try this one

$('.editable_selectiva select').change(function(){
    tally('p#subtotal');
    tally('p#total');
});

Upvotes: 1

DDK
DDK

Reputation: 1038

Bind a change event to the select. Add this code

$('p.editable_selectiva').change(function() {
    tally('p#subtotal');
    tally('p#total');
});

Upvotes: 1

Related Questions