I want to alert the total amount calculated but I don't know why instead of calculating its just appending the values.
The code:
$('#main button').click(function(){
id = $(this).attr('id');
parts = id.split('_');
item_id = parts[0];
pairs = $('#'+item_id+'_pairs').val();
females = $('#'+item_id + '_females').val();
males = $('#'+item_id + '_males').val();
if(pairs >0){
counted_pairs = pairs*2;
}else{
counted_pairs = 0;
}
total_fishes = (males + females + counted_pairs);
alert(total_fishes);
});
If I add 1 pair 1 male and 1 female in form it should show 4 total but its showing 111 seems appending not calculating?