Alvin Bakker was close, but it needed a bit more tuning.
The problem is that you run over each row, including the header row. The header row doesn't contain the values you want, so it runs into an error, and javascript stops execution on errors.
A simple way to solve this, is by checking if you're in the header row:
$('table .ilosc, table .cena_netto .stawka_vat').on('keyup paste change', function() {
$('table tr').each(function() {
//NEW CODE HERE:
//Pseudo code: if this row contains <th>-elements,
//then don't bother with it and move on to the next row.
if ($(this).find('th').length > 0)
return;
var ilosc = $(this).find('input.ilosc').val();
var cena_netto = $(this).find('input.cena_netto').val();
var wartosc_netto = (ilosc * cena_netto);
$(this).find('input.wartosc_netto').val(wartosc_netto);
var stawka_vat = $(this).find('input.stawka_vat').val().replace('%', '');
var kwota_vat = ( wartosc_netto * (stawka_vat / 100) );
$(this).find('input.kwota_vat').val(kwota_vat);
var wartosc_brutto = (wartosc_netto + kwota_vat);
$(this).find('input.wartosc_brutto').val(wartosc_brutto);
}); //END .each
return false;
}); // END change
Alternative solution (inspired by comment of @SlashmanX)
You could also adapt your html a bit:
Put your first row in a <thead>
element. Like this:
<table>
<thead>
<tr>
<th>Lp.</th>
<th>Nazwa towaru lub usługi</th>
<th>Jednostka</th>
<th>Ilość</th>
<th>Cena netto</th>
<th>Wartość netto</th>
<th>Stawka VAT</th>
<th>Kwota VAT</th>
<th>Wartość brutto</th>
</tr>
</thead>
<!-- All data rows below -->
</table>
Then you can adapt your javascript like this:
$('table .ilosc, table .cena_netto .stawka_vat').on('keyup paste change', function() {
//Subtle difference in this line: Spot the '>' in the selector!
$('table>tr').each(function() {
var ilosc = $(this).find('input.ilosc').val();
var cena_netto = $(this).find('input.cena_netto').val();
var wartosc_netto = (ilosc * cena_netto);
$(this).find('input.wartosc_netto').val(wartosc_netto);
var stawka_vat = $(this).find('input.stawka_vat').val().replace('%', '');
var kwota_vat = ( wartosc_netto * (stawka_vat / 100) );
$(this).find('input.kwota_vat').val(kwota_vat);
var wartosc_brutto = (wartosc_netto + kwota_vat);
$(this).find('input.wartosc_brutto').val(wartosc_brutto);
}); //END .each
return false;
}); // END change
Again: credit to SlashmanX for pointing this out.