How to multiply 2 cells in row?
How to multiply 2 cells in row?
Ilian_99
Posts: 4Questions: 3Answers: 0
$(document).ready(function() {
var count = 0;
$(document).on('click', '.add_distribution', function() {
count++;
var html = '';
html += '<tr>';
html += '<td><select name="item_ArtName[]" class="form-control item_ArtName" data-sub_category_id="' + count + '"><option value="">Select art</option><?php echo fill_select_box($connect); ?></select></td>';
html += '<td><input name="item_Qty[]" class="form-control item_Qty" id="qty_2' + count + '" /></td>';
html += '<td><input name="item_Price[]" class="form-control item_Price" id="price_2' + count + '" /></td>';
html += '<td><input name="item_Total[]" class="form-control item_Total" id="total_2' + count + '" readonly /></td>';
html += '<td><button type="button" name="remove" class="btn btn-danger btn-xs remove"><span class="glyphicon glyphicon-minus"></span></button></td>';
$('.distribution_mod').append(html);
$('#price_2' + count + ', #qty_2' + count + '').keyup(function() {
var count_number = count;
var price = parseFloat($('#price_2' + count_number + '').val());
var qty = parseFloat($('#qty_2' + count_number + '').val());
$('#total_2' + count_number + '').val(price * qty);
});
});
//count problem
}
);
.....
Hello i have problem with this part of my code. As u can see this function add new row when button is clicked. I wanna multiply qty and price on every row and be able to change the price or quantity at any time. this code work only on currently row, when i try to change previous row this affect currently row because "count". Please help me solve this problem .
This question has an accepted answers - jump to answer
Answers
A rendering function is what you want.
Allan