Good evening everyone. Tell me how to make the multiplication of the values ​​in the cells correctly. There are text fields in the cells of the table, the values ​​of which just need to be multiplied by clicking on the button 'Calculate the cost'. The table is formed in the same way:

var outputData = document.getElementById("outputData"); var total = outputData.getElementsByTagName("TH"); var regExp = new RegExp(/([VPFERUL]+)\s\(x(\d+)\)/g); var table = "<table class = 'calculator'>"; table += "<tr><th></th><th>Цена(кр)</th><th>Кол-во</th><th>Сумма</th></tr>"; for(var i=0;i<total.length;i++){ var result = total[i].firstChild.nodeValue.match(regExp); table += "<tr>"; table += "<td width = '40px' class="+RegExp.$1+"><b>"+RegExp.$1+"</b></td>"; table += "<td width = '110px'><input type = 'text' size= '6' maxlength = '6'></td>"; table += "<td width = '110px'><input type = 'text' size = '6' value = "+RegExp.$2+"></td>"; table += "<td></td></tr>"; } table += "<tr><td colspan = '4'><input type = 'button' id = 'count' value = 'Посчитать стоимость'></td></tr>" table += "</table>"; calculator.innerHTML = table; 
  • 2
    the table is formed in a retarded manner - deivan_
  • then tell me what's better - quaresma89
  • one
    via document.createElement of course. - deivan_
  • And what is the difference? - quaresma89
  • one
    @ Zhenka Sidorov that you can store cell references in an array. - zb '

0