When values are entered into 2 TextBox's(textbox1 & textbox2) they are multiplied with one another and the answer is displayd in a Label(label1), I need to add all the labels and display it in another label, this has to be don without buttons.

When the TextBox's change this function is called.

function Calculate(textbox1, textbox2, label1)
    {
            var txt1 = 0;
            var txt2 = 0;
            txt1 = document.getElementById(textbox1).value;
            if (txt1 == "")
                txt1 = 0;
            
            txt2 =  document.getElementById(textbox2).value;
            if (txt2 == "")
                txt2 = 0;

            var cost = txt1 * txt2;
            document.getElementById(label1).innerHTML = cost;
    }

at the end of calculate function you may add code

FUNCTION CALCULATE
{
.
.
.
.
     document.getElementById(label1).innerHTML = cost;

     document.getElementById(label3).innerHTML = parseFloat(document.getElementById(label1).innerHTML) + parseFloat(document.getElementById(label2).innerHTML);
}

Ok, this function is called about 15times, so I'm not sure how to get all the labels to asdd together for

document.getElementById(label3).innerHTML = 
            parseFloat(document.getElementById(label1).innerHTML) + 
            parseFloat(document.getElementById(label2).innerHTML);
var total=0;
for (i=1;i<=15;i++)
{
  total+=parseFloat(document.getElementById('label'+i).innerHTML); 
}
document.getElementById(label3).innerHTML = total;

I tried the code and "label3" doesn't change.

post/attache your whole code.

Thanks for the help.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="input.aspx.cs" Inherits="input" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<script type="text/javascript">
    var total = 0;

    function Currency() {  
         var val1 = document.getElementById('currency_txt').value;  
         
             document.getElementById('rateSymbol').innerHTML = val1; 
             document.getElementById('amountSymbol').innerHTML = val1; 
             document.getElementById('rentalSymbol').innerHTML = val1;  
    }  

    function CalculateAmount(textbox1, textbox2, label1, label2)
    {
            var txt1 = 0;
            var txt2 = 0;
            
            txt1 = document.getElementById(textbox1).value;
            if (txt1 == "")
                txt1 = 0;
            
            txt2 =  document.getElementById(textbox2).value;
            if (txt2 == "")
                txt2 = 0;

            var cost = txt1 * txt2;
            document.getElementById(label1).innerHTML = cost;
            
      var total = 0;
      for (i = 1 ;i <= 15; i++)
      {
        total += parseFloat(document.getElementById('label'+i).innerHTML);
      }
      document.getElementById(label2).innerHTML = total;
      
    }
    
</script>  
    
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>Financial Viability Input</title>
</head>

<body class="body">
    <form id="form1" runat="server">

    <h1 class="center">FINANCIAL VIABILITY FOR A RENTAL SCHEME</h1>

    <h2>INPUT:</h2>
    <h3 class="right"><asp:Label ID="todayDate" runat="server" /></h3>

    <b>GENERAL</b>
    <table id="generalTable" runat="server" >
        <tr>
            <td class="contentPad">Name of Project</td>
            <td><asp:TextBox ID="name_txt" runat="server" CssClass="txtLeft" Text="Menlyn Corporate Park" CausesValidation="false" /></td>
            <td><asp:RequiredFieldValidator id="nameRequired" runat="server" Display="Dynamic"
                    ErrorMessage="Project Name is Required!" CssClass="validators"
                    ControlToValidate="name_txt">
                </asp:RequiredFieldValidator>
            </td>
        </tr>
        
        <tr>
            <td class="contentPad">Currency (eg R, US$, etc)</td>
            <td>
                <asp:TextBox ID="currency_txt" runat="server" CssClass="txtLeft" Text="R" /></td>
            <td><asp:RegularExpressionValidator ID="currencyValidate" ControlToValidate="currency_txt" 
                    runat="server" ErrorMessage="Not a valid Currency Symbol!" CssClass="validators"
                    ValidationExpression="[RfpKMPknrLFtJsMTC£$]{1,2}" Display="Dynamic">
                </asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator id="currencyRequired" runat="server"
                    ErrorMessage="Currency Symbol is Required!" CssClass="validators"
                    ControlToValidate="currency_txt" Display="Dynamic">
                </asp:RequiredFieldValidator>
            </td>
        </tr>
      </table>
        
    <b>PROGRAMME</b>
    <table id="programmeTable" runat="server" >
        <tr>
            <td class="contentPad">Expected Date of Tender</td>
            <td><asp:TextBox ID="start_txt" runat="server" CssClass="txtLeft" Text="03/06/2010" /></td>
            <td><asp:RegularExpressionValidator ID="startValidate" ControlToValidate="start_txt" CssClass="validators"
                    runat="server" ErrorMessage="Invalid Date or not dd/mm/yyyy format!" Display="dynamic" 
                    ValidationExpression="(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))">
                </asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator id="startRequired" runat="server" CssClass="validators"
                    ErrorMessage="Tender Date is Required!" ControlToValidate="start_txt"
                    Display="dynamic">
                </asp:RequiredFieldValidator>
            </td>
        </tr>
        
        <tr>
            <td class="contentPad">Expected Date of Completion of Development </td>
            <td><asp:TextBox ID="completion_txt" runat="server" CssClass="txtLeft" Text="03/06/2011" /></td>
            <td><asp:RegularExpressionValidator ID="completionValidate" ControlToValidate="completion_txt" 
                    runat="server" ErrorMessage="Invalid Date or not dd/mm/yyyy format!" 
                    Display="Dynamic" CssClass="validators"
                    ValidationExpression="(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))" >
                </asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator id="completionRequired" runat="server"
                    ErrorMessage="Completion Date is Required!" CssClass="validators"
                    ControlToValidate="completion_txt" Display="dynamic">
                </asp:RequiredFieldValidator>
               </td>    
        </tr>
    </table><br />
    
    <b>CAPITAL INVESTMENT</b>    
    <table id="capitalTable" runat="server" class="table">
        <tr class="left">
            <td class="pad"><b>Construction Cost</b></td>
        </tr>
        
         <tr class="left">
            <td class="contentPad"><b>Current Construction Cost</b></td>
        </tr>
        
        <tr class="center">
            <td class="tableHeadings"><h4>Description</h4></td>
            <td class="tableHeadings"><h4>Area<br />m2</h4></td>
            <td class="tableHeadings"><h4>Rate/m2<br />
               <asp:Label ID="rateSymbol" runat="server" Text="R" />/m2</h4></td>
            <td class="tableHeadings"><h4>Amount<br />
                <asp:Label ID="amountSymbol" runat="server" Text="R" /></h4></td>
        </tr>
        
        <tr class="example">
            <td class="left">Basement</td>
            <td>100,000</td>
            <td>2,750</td>
            <td>275,000,000</td>
        </tr>
       
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_01" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_01" runat="server" onkeyup="Calculate('area_01','rate_01','amount_01', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_01" runat="server" onkeyup="Calculate('area_01','rate_01','amount_01', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_01" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_02" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_02" runat="server" onkeyup="Calculate('area_02','rate_02','amount_02', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_02" runat="server" onkeyup="Calculate('area_02','rate_02','amount_02', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_02" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_03" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_03" runat="server" onkeyup="Calculate('area_03','rate_03','amount_03', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_03" runat="server" onkeyup="Calculate('area_03','rate_03','amount_03', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_03" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_04" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_04" runat="server" onkeyup="Calculate('area_04','rate_04','amount_04', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_04" runat="server" onkeyup="Calculate('area_04','rate_04','amount_04', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_04" runat="server" Width="150px" /></td>
        </tr>
       
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_05" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_05" runat="server" onkeyup="Calculate('area_05','rate_05','amount_05', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_05" runat="server" onkeyup="Calculate('area_05','rate_05','amount_05', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_05" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_06" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_06" runat="server" onkeyup="Calculate('area_06','rate_06','amount_06', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_06" runat="server" onkeyup="Calculate('area_06','rate_06','amount_06', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_06" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_07" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_07" runat="server" onkeyup="Calculate('area_07','rate_07','amount_07', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_07" runat="server" onkeyup="Calculate('area_07','rate_07','amount_07', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_07" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_08" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_08" runat="server" onkeyup="Calculate('area_08','rate_08','amount_08', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_08" runat="server" onkeyup="Calculate('area_08','rate_08','amount_08', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_08" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_09" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_09" runat="server" onkeyup="Calculate('area_09','rate_09','amount_09', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_09" runat="server" onkeyup="Calculate('area_09','rate_09','amount_09', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_09" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_10" runat="server"  Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_10" runat="server" onkeyup="Calculate('area_10','rate_10','amount_10', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_10" runat="server" onkeyup="Calculate('area_10','rate_10','amount_10', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_10" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_11" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_11" runat="server" onkeyup="Calculate('area_11','rate_11','amount_11', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_11" runat="server" onkeyup="Calculate('area_11','rate_11','amount_11', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_11" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_12" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_12" runat="server" onkeyup="Calculate('area_12','rate_12','amount_12', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_12" runat="server" onkeyup="Calculate('area_12','rate_12','amount_12', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_12" runat="server" Width="150px" /></td>
        </tr>
               
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_13" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_13" runat="server" onkeyup="Calculate('area_13','rate_13','amount_13', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_13" runat="server" onkeyup="Calculate('area_13','rate_13','amount_13', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_13" runat="server" Width="150px" /></td>
        </tr>

        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_14" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_14" runat="server" onkeyup="Calculate('area_14','rate_14','amount_14', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_14" runat="server" onkeyup="Calculate('area_14','rate_14','amount_14', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_14" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableRows">
            <td class="inputColor">
                <asp:TextBox ID="desc_15" runat="server" Width="320px" CssClass="txtLeftTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="area_15" runat="server" onkeyup="Calculate('area_15','rate_15','amount_15', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td class="inputColor">
                <asp:TextBox ID="rate_15" runat="server" onkeyup="Calculate('area_15','rate_15','amount_15', 'estimateCost')" Width="150px" CssClass="txtRightTable" /></td>
            <td><asp:Label ID="amount_15" runat="server" Width="150px" /></td>
        </tr>
        
        <tr class="tableHeadings">
            <td class="warp"><h4 class="left">TOTAL ESTIMATED CURRENT CONSTRUCTION COST</h4></td>
            <td /><td />
            <td><asp:Label ID="estimateCost" runat="server" Text="0" /></td>
        </tr>
    </table><br />
    
    <b>ESCALATION</b><br />
    <b>Escalation in construction cost as a percentage per annum or calculated (per Medium Term Forecasting Associates)</b>
    <table id="escalationTable" runat="server" >
        <tr>
            <td />
            <td><asp:DropDownList ID="excalation_selection" runat="server" Width="275px" >
                <asp:ListItem>Percentage</asp:ListItem>
                <asp:ListItem>Calculation</asp:ListItem>
            </asp:DropDownList></td>
        </tr>
        
        <tr>
            <td class="contentPad">Pre-contract Escalation (% per month)</td>
            <td><asp:TextBox ID="preContract_txt" CssClass="txtRight" runat="server" Text="1" /></td>
             <td><asp:RegularExpressionValidator ID="preContractValidate" ControlToValidate="preContract_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td class="contentPad">Post-contract Escalation (% per month)</td>
            <td><asp:TextBox ID="postContract_txt" CssClass="txtRight" runat="server" Text="3" /></td>
             <td><asp:RegularExpressionValidator ID="postContractValidate" ControlToValidate="postContract_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Professional Fees</b></td>
        </tr>
        
        <tr>
            <td class="contentPad">Percentage of construction cost including disbursements (%)</td>
            <td><asp:TextBox ID="costPercentage_txt" CssClass="txtRight" runat="server" Text="13.00%" /></td>
            <td><asp:RegularExpressionValidator ID="costPercentageValidate" ControlToValidate="costPercentage_txt" 
                    runat="server" ErrorMessage="Not a Valid Cost!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Property Value</b></td>
        </tr>
        <tr>
            <td class="contentPad">Property Value (Current market value of property)</td>
            <td><asp:TextBox ID="propertyValue_txt" CssClass="txtRight" runat="server" Text="5,000,000" /></td>
            <td><asp:RegularExpressionValidator ID="propertyValueValidate" ControlToValidate="propertyValue_txt" 
                    runat="server" ErrorMessage="Not a Valid Cost!" Display="Dynamic"
                    ValidationExpression="^\$?(\d{1,3}[, ]?(\d{3}[, ]?)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{2})?)$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Local Authority Charges</b></td>
            <td><asp:TextBox ID="authority_txt" CssClass="txtRight" runat="server" Text="2,500,000" /></td>
            <td><asp:RegularExpressionValidator ID="authorityValidate" ControlToValidate="authority_txt" 
                    runat="server" ErrorMessage="Not a Valid Cost!" Display="Dynamic"
                    ValidationExpression="^\$?(\d{1,3}[, ]?(\d{3}[, ]?)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{2})?)$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="contentPad"><u>Allow for:</u> Plan approval fees, interim tax on land and improvements, bulk services charges, etc</td>
        </tr>
        
        <tr>
            <td><b>Development, Pre-Opening and Marketing Costs</b></td>
            <td><asp:TextBox ID="developmentCosts_txt" CssClass="txtRight" runat="server" Text="750,000" /></td>
            <td><asp:RegularExpressionValidator ID="developmentValidate" ControlToValidate="developmentCosts_txt" 
                    runat="server" ErrorMessage="Not a Valid Cost!" Display="Dynamic"
                    ValidationExpression="^\$?(\d{1,3}[, ]?(\d{3}[, ]?)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{2})?)$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="contentPad"><u>Allow for:</u> Leasing commissions, non-recoverable tenant requirement costs, furnishings, fixtures and equipment costs, etc</td>
        </tr>
        
        <tr>
            <td><b>Tenanting Costs</b></td>
            <td><asp:TextBox ID="tenantingCost_txt" CssClass="txtRight" runat="server" Text="4,500,000" /></td>
            <td><asp:RegularExpressionValidator ID="tenantingValidate" ControlToValidate="tenantingCost_txt" 
                    runat="server" ErrorMessage="Not a valid Cost!" Display="Dynamic"
                    ValidationExpression="^\$?(\d{1,3}[, ]?(\d{3}[, ]?)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{2})?)$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="contentPad"><u>Allow for:</u> Leasing commissions, non-recoverable tenant requirement costs, furnishings, fixtures and equipment costs, etc</td>
        </tr>
        
        <tr>
            <td><b>Financing Costs</b></td>
        </tr>
        <tr>
            <td class="contentPad">Bank loan as percentage of total capital investment</td>
            <td><asp:TextBox ID="bankLoan_txt" runat="server" CssClass="txtRight" Text="70%" /></td>
            <td><asp:RegularExpressionValidator ID="bankLoanValidate" ControlToValidate="bankLoan_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td class="contentPad">Finance Raising Fee (%)</td>
            <td><asp:TextBox ID="financeRaise_txt" runat="server" CssClass="txtRight" Text="1.50%" /></td>
            <td><asp:RegularExpressionValidator ID="financeRaiseValidate" ControlToValidate="financeRaise_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Cost of Capital</b></td>
        </tr>
        <tr>
            <td class="contentPad">Insert average interest rate to allow for interest on bank loan as well as loss of interest on own capital</td>
        </tr>
        <tr>
            <td class="contentPad">Interest rate (%)</td>
            <td><asp:TextBox ID="interestRate_txt" runat="server" CssClass="txtRight" Text="10.50%" /></td>
            <td><asp:RegularExpressionValidator ID="interestRateValidate" ControlToValidate="interestRate_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
    </table><br />
    
    <table id="finalTable" runat="server">
        <tr>
            <td><b>Operating Expenses</b></td>
        </tr>
        
        <tr>
            <td class="contentPad">Operating expenses as a percentage of gross income (%) (insert zero if above rental is a net rental)</td>
            <td><asp:TextBox ID="operatingExpense_txt" runat="server" CssClass="txtRight"  Text="15.00%" /></td>
            <td><asp:RegularExpressionValidator ID="operatingExpenseValidate" ControlToValidate="operatingExpense_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator id="operatingExpenserequire" runat="server"
                    ErrorMessage="Operating Expense is Required!" CssClass="validators"
                    ControlToValidate="operatingExpense_txt" Display="Dynamic">
                </asp:RequiredFieldValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Escalation Rate of Rental</b></td>
        </tr>
        
        <tr>
            <td class="contentPad">Average escalation per annum of rental income (%)</td>
            <td><asp:TextBox ID="escalationRental_txt" runat="server" CssClass="txtRight" Text="8.00%" /></td>
            <td><asp:RegularExpressionValidator ID="EscalationRentalValidate" ControlToValidate="escalationRental_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Escalation Rate of Operating Expenses</b></td>
        </tr>
        <tr>
            <td class="contentPad">Average Escalation Rate per annum of Operating Expenses (%)</td>
            <td><asp:TextBox ID="averageEscalation_txt" runat="server" CssClass="txtRight" Text="7.00%" /></td>
            <td><asp:RegularExpressionValidator ID="averageEscalationValidate" ControlToValidate="averageEscalation_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Capitalisation rate to determine end value</b></td>
        </tr>
        <tr>
            <td class="contentPad">Capitalisation rate for end value (%)</td>
        </tr>
        
        <tr>
            <td style="padding-left: 300px;">Afer 5 Years</td>
            <td><asp:TextBox ID="fiveYears_txt" runat="server" CssClass="txtRight" Text="11.00%" /></td>
            <td><asp:RegularExpressionValidator ID="fiveYearsValidate" ControlToValidate="fiveYears_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td style="padding-left: 300px;">Afer 20 Years</td>
            <td><asp:TextBox ID="twentyYears_txt" runat="server" CssClass="txtRight" Text="14.00%" /></td>
            <td><asp:RegularExpressionValidator ID="twenetyYearsValidate" ControlToValidate="twentyYears_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        
        <tr>
            <td><b>Vacancy rate for IRR Calculation</b></td>
        </tr>
        
        <tr>
            <td class="contentPad">Vacancy rate (%)</td>
        </tr>
        
        <tr>
            <td style="padding-left: 300px;">Year 1</td>
            <td><asp:TextBox ID="vacancyOne_txt" runat="server" CssClass="txtRight" Text="5.00%" /></td>
            <td><asp:RegularExpressionValidator ID="vacancyOneValidate" ControlToValidate="vacancyOne_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td style="padding-left: 300px;">Onwards</td>
            <td><asp:TextBox ID="vacancyOnwards_txt" runat="server" CssClass="txtRight" Text="2.50%" /></td>
            <td><asp:RegularExpressionValidator ID="vacancyOnwardsValidate" ControlToValidate="vacancyOnwards_txt" 
                    runat="server" ErrorMessage="Not a Valid Percentage!" Display="Dynamic"
                    ValidationExpression="^\d{0,2}(\.\d{1,4})? *%?$" CssClass="validators">
                </asp:RegularExpressionValidator>
            </td>
        </tr> 
    </table><br />
    
    <asp:Button ID="submit" runat="server" CssClass="center" Text="Submit" OnClick="submit_Click"/>
     
    </form>
</body>
</html>

change you calculate function at the end as shown below

function calcuate(...........)
{
.
.
.
.

var total = 0;      
for (i = 1 ;i <= 15; i++)      
{        
	if (i<10)
	{
		total += parseFloat(document.getElementById('amount_0'+i).innerHTML);      
	}
	else
	{
		total += parseFloat(document.getElementById('amount_'+i).innerHTML);      
	}
}      
document.getElementById(label2).innerHTML = total;

}

Hi urtrivedi,

thanks for the function, but when the totalLabel should change it says NaN, I know this means not a number, although only numbers are entered into the TextBox.

Member Avatar for rajarajan2017

Test with eval() function in javascript to convert the element value/expression to process a calculation.

http://www.w3schools.com/jsref/jsref_eval.asp

rajarajan07,

I will check it out.

I hope this will work

function calculate(.......)
{
 .
 .
 .
 .
 
	var total = 0;      
	for (i = 1 ;i <= 15; i++)      
	{        
		if (i<10)
			labelname='amount_0'+i;
		else
			labelname='amount_'+i;
	
	
		if (!isNaN(parseFloat(document.getElementById(labelname).innerHTML)))
			total += parseFloat(document.getElementById(labelname).innerHTML);      
	}      
	
	document.getElementById(label2).innerHTML = total;
}

Works Perfect!!

Thanks for all the help, I really appreciate it.

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.