Nollyvenon 0 Newbie Poster

I designed an invoice system that add rows automatically and computes the results, print it in another file that can be downloaded by other users.can i get help on how to multiply the price and quantity to get amount?

this is my code:


<SCRIPT LANGUAGE="JavaScript">
function showamt() {

//var unitprice = document.form1.unitprice[].value;
//var qty = document.form1.qty[].value;
//amount = unitprice*qty;
//document.form1.amount[].value = amount;

var a= document.getElementById('unitprice[this]');
var b= document.getElementById('qty[this]');
var c = Math.ceil(a.value*b.value);
alert(b);
document.getElementById('amount[this]').value =c;
}

</script>
<SCRIPT language="javascript">
function addRow(tableID) {

var table = document.getElementById(tableID);

var rowCount = table.rows.length;
var row = table.insertRow(rowCount);

var colCount = table.rows[0].cells.length;

for(var i=0; i<colCount; i++) {

var newcell = row.insertCell(i);

newcell.innerHTML = table.rows[0].cells.innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}

switch(newcell.childNodes[0].name) {
case "s_no[]":
newcell.childNodes[0].value = rowCount + 1;
break;
}
}
}

function deleteRow(tableID) {
var tbl = document.getElementById(tableID);
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);

}

</SCRIPT>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.