This is my javascript code. here i am trying to multiple two values in each row (totally 7 rows) and then doing addition operation at end of the table. its worked but problem is NaN. when i entered all fields then only it shows the final value. if user entered 5 rows values it shows NaN. I want if they didn't entered few rows remaining rows will be caluculated and shown in text box. how to do....???
function doCal() {
var nValue;
var nValue1;
nValue = document.getElementById("noofnights").value;
nValue1 = document.getElementById("rate").value;
amount=(nValue*nValue1);
document.getElementById("total").value=amount;
var nValue2;
var nValue3;
nValue2 = document.getElementById("noofnights1").value;
nValue3 = document.getElementById("rate1").value;
amount=(nValue2*nValue3);
document.getElementById("total1").value=amount;
var nValue4;
var nValue5;
nValue4 = document.getElementById("noofnights2").value;
nValue5 = document.getElementById("rate2").value;
amount=(nValue4*nValue5);
document.getElementById("total2").value=amount;
var nValue6;
var nValue7;
nValue6 = document.getElementById("noofnights3").value;
nValue7 = document.getElementById("rate3").value;
amount=(nValue6*nValue7);
document.getElementById("total3").value=amount;
var nValue8;
var nValue9;
nValue8 = document.getElementById("noofnights4").value;
nValue9 = document.getElementById("rate4").value;
amount=(nValue8*nValue9);
document.getElementById("total4").value=amount;
var nValue10;
var nValue11;
nValue10 = document.getElementById("noofnights5").value;
nValue11 = document.getElementById("rate5").value;
amount=(nValue10*nValue11);
document.getElementById("total5").value=amount;
var nValue12;
var nValue13;
nValue12 = document.getElementById("noofnights6").value;
nValue13 = document.getElementById("rate6").value;
amount=(nValue12*nValue13);
document.getElementById("total6").value=amount;
//total amount
totalamount=(nValue*nValue1) + (nValue2*nValue3) + (nValue4*nValue5) + (nValue6*nValue7) + (nValue8*nValue9) + (nValue10*nValue11) + (nValue12*nValue13);
document.getElementById("totalamount").value=totalamount;
}