I'm trying to multiply 2 values from input box and store it in the last row of that column. The adding works perfectly for this but the multiplication does not work.
I want to multiply all the row inputs. I got an example for addition why doesn't multiplication work ?
I've tried
tot *= Number($(this).val()) || 0 //this does't work.
tot = ((tot) * (Number($(this).val()) || 0)) //this doesn't work.
$('table input').on('input', function() { var $tr = $(this).closest('tr'); // get tr which contains the input var tot = 0; // variable to sore sum $('input', $tr).each(function() { // iterate over inputs tot += Number($(this).val()) || 0 // i want to multiply here. The addition works perfectly }); $('td:last', $tr).text(tot); // update last column value }).trigger('input'); // trigger input to set initial value in columns
this does't work?tot *= Number($(this).val()) || 0i get the output as 0 so the multiplication doesn't work. I'm supposed to get the value of the 2 inputs multiplicative output . i.e,500 * 2 = 1000.Thanks :D