Good day! I am trying to create a table layout in which there will be an indefinite number of rows, but it is necessary to dynamically calculate the sum of 2x input in a row and output it to the third. How to create a dynamic definition of ID input in a string for further manipulation of their values?
<body> <table border="1"> <thead> <tr><th>№</th> <th>Цена</th> <th>Кол-во</th> <th>Сумма</th> </tr> </thead> <tbody> <tr> <td><input type="text" id="num" value="1"> </td> <td><input type="text" id="cena1"> </td> <td><input type="text" id="kol_vo1"> </td> <td><input type="text" id="sum1"> </td> </tr> <tr> <td><input type="text" id="num" value="2"></td> <td><input type="text" id="cena2"> </td> <td><input type="text" id="kol_vo2"></td> <td><input type="text" id="sum2"></td> </tr> </tbody> </table> <script> ed1=document.getElementById("cena1"); ed2=document.getElementById("kol_vo1"); ed1.oninput = function() { document.getElementById('sum1').value = Number(ed1.value)*Number(ed2.value); } ed2.oninput = function() { document.getElementById('sum1').value = Number(ed1.value)*Number(ed2.value); } </script> </body>