Hi I've got the JavaScript that calculates the amount of two TextBox's(rate_## and area_##) and displayes it in a label(amount_##), what I'm trying to do is to add up all of the amounts and display it in another label(estimatedCost), I've tried this with the first function but the estimatedCost label displays NaN.
<script type="text/javascript">
var estimatedCost;
function Amount01() {
var val1 = document.getElementById('area_01').value;
var val2 = document.getElementById('rate_01').value;
if (val1 != '' && val2 != '')
estimatedCost += val1 * val2;
document.getElementById('amount_01').innerHTML = val1 * val2;
document.getElementById('estimateCost').innerHTML = estimatedCost;
}
function Amount02() {
var val1 = document.getElementById('area_02').value;
var val2 = document.getElementById('rate_02').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_02').innerHTML = val1 * val2;
}
function Amount03() {
var val1 = document.getElementById('area_03').value;
var val2 = document.getElementById('rate_03').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_03').innerHTML = val1 * val2;
}
function Amount04() {
var val1 = document.getElementById('area_04').value;
var val2 = document.getElementById('rate_04').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_04').innerHTML = val1 * val2;
}
function Amount05() {
var val1 = document.getElementById('area_05').value;
var val2 = document.getElementById('rate_05').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_05').innerHTML = val1 * val2;
}
function Amount06() {
var val1 = document.getElementById('area_06').value;
var val2 = document.getElementById('rate_06').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_06').innerHTML = val1 * val2;
}
function Amount07() {
var val1 = document.getElementById('area_07').value;
var val2 = document.getElementById('rate_07').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_07').innerHTML = val1 * val2;
}
function Amount08() {
var val1 = document.getElementById('area_08').value;
var val2 = document.getElementById('rate_08').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_08').innerHTML = val1 * val2;
}
function Amount09() {
var val1 = document.getElementById('area_09').value;
var val2 = document.getElementById('rate_09').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_09').innerHTML = val1 * val2;
}
function Amount10() {
var val1 = document.getElementById('area_10').value;
var val2 = document.getElementById('rate_10').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_10').innerHTML = val1 * val2;
}
function Amount11() {
var val1 = document.getElementById('area_11').value;
var val2 = document.getElementById('rate_11').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_11').innerHTML = val1 * val2;
}
function Amount12() {
var val1 = document.getElementById('area_12').value;
var val2 = document.getElementById('rate_12').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_12').innerHTML = val1 * val2;
}
function Amount13() {
var val1 = document.getElementById('area_13').value;
var val2 = document.getElementById('rate_13').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_13').innerHTML = val1 * val2;
}
function Amount14() {
var val1 = document.getElementById('area_14').value;
var val2 = document.getElementById('rate_14').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_14').innerHTML = val1 * val2;
}
function Amount15() {
var val1 = document.getElementById('area_15').value;
var val2 = document.getElementById('rate_15').value;
if (val1 != '' && val2 != '')
document.getElementById('amount_15').innerHTML = val1 * val2;
}
</script>