<script language="JavaScript">
function sumx()
{
var pro = parseFloat(document.formx.pro.value);
var data1 = document.getElementsByName("data1[]");
var todata2 = document.getElementsByName("todata2[]");
var todata3 = document.getElementsByName('todata3[]');
var total_cost = 0;
var sum = 0;
var count = data1.length;
for(var a=0;a<count;a++){
if(a!=0){
var aa= a-1;
todata2[a].value = pro * data1[a].value;
todata3[a].value = parseFloat(todata2[a].value) + parseFloat(todata3[aa].value) ;
}else{
todata2[a].value = pro * data1[a].value;
todata3[a].value = pro * data1[a].value;
}
}
}
function addRow(){
var myTbody=document.getElementById('datatable');
newRow=myTbody.firstChild.cloneNode(true);
myTbody.appendChild(newRow);
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 1) {
alert("Cannot delete all the rows.");
break;
}
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}