I have c # code in asp.net view: (It create time inputs for me with the class described)
View:
<td id="td01">@Html.TextBoxFor(m => m.Model1[nr_rows].Rozpoczecie, new { @class = "start", @type = "time" })</td>
<td id="td01">@Html.TextBoxFor(m => m.Model1[nr_rows].Zakonczenie, new { @class = "end", @type = "time" })</td>
<td id="td01">@Html.TextBoxFor(m => m.Model1[nr_rows].OdbiorGodzin, new { @class = "gethours", @type = "time" })</td>
<td id="td01">@Html.TextBoxFor(m => m.Model1[nr_rows].DniOdpracowania, new { @class = "additional_free",@type = "time", @readonly = true })</td>
<td id="td01">@Html.TextBoxFor(m => m.Model1[nr_rows].SaldoNadgodzin, new { @class = "overtime", @type = "time", @readonly = true })</td>
And I have a code that does various calculations for me:
JavaScript
table.addEventListener('change', function (e) {
const classList = e.target.classList;
if (classList.contains('start') || classList.contains('end') || classList.contains('gethours')) {
const tr = e.target.parentNode.parentNode;
const [additional_free, overtime] = [...tr.querySelectorAll('.additional_free,.overtime')];
additional_free.value = overtime.value <<<<<<<<<< this
}
});
Although everything works, I get such an unknown for me error:
> VM49:85 Uncaught TypeError: Cannot read property 'value' of undefined
at HTMLTableElement.<anonymous> (<anonymous>:85:42)
I will add that the data at the beginning are read from the database and set as the initial values in this table
What I have tried:
Anybody knows what's going on?