I am making an php , mysql website for billing... I want to get the sum of the values in text box.. The rows can be added according to the user requirement... but .. I tried most of things.. but not getting right.... how to get the sum of all the textbox values in the last column rate... I mean without any user input such as button click..... could somebody help me with this code.....
thanks in advance..
code I made for adding rows to table..
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "text";
element1.name="s_no[]";
element1.size="25";
element1.value = rowCount;
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
var element2 = document.createElement("input");
element2.type = "text";
element2.name="p_id[]";
element2.size="25";
cell2.appendChild(element2);
var cell3 = row.insertCell(2);
var element3 = document.createElement("input");
element3.type = "text";
element3.name="p_name[]";
element3.size="25";
cell3.appendChild(element3);
var cell5 = row.insertCell(3);
var element5 = document.createElement("input");
element5.type = "text";
element5.name="mrp[]";
element5.size="25";
cell5.appendChild(element5);
var cell6 = row.insertCell(4);
var element6 = document.createElement("input");
element6.type = "text";
element6.name = "qty[]";
element6.size="25";
cell6.appendChild(element6);
var cell7 = row.insertCell(5);
var element7 = document.createElement("input");
element7.type = "text";
element7.name = "rate[]";
element7.size="25";
cell7.appendChild(element7);
var cell8 = row.insertCell(6);
var element8 = document.createElement("input");
element8.type = "checkbox";
element8.name = "check";
cell8.appendChild(element8);
}
Html code for table:
<th width="17%"><label>S.No</label></th>
<th width="17%">Product Id</th>
<th width="17%">Product Name</th>
<th width="17%">MRP</th>
<th width="17%">Qty</th>
<th width="18%">Rate</th>
<th width="18%">Check</th>
</tr>
Total