Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
How to perform addition of asp.net textbox values using javascript? the result textbox value should change automatically
    <script language="javascript" type="text/javascript">

function sumCalc() {
    var _txt1 = document.getElementById('<%= TextBox1.ClientID %>');
    var _txt2 = document.getElementById('<%= TextBox2.ClientID %>');
    var _txt3 = document.getElementById('<%= TextBox3.ClientID %>');
    var _txt4 = document.getElementById('<%= TextBox4.ClientID %>');
    var _txt5 = document.getElementById('<%= TextBox5.ClientID %>');
    var t1 = 0, t2 = 0, t3 = 0, t4 = 0;

    if (txt1.value != "") t1 = txt1.value;
    if (txt2.value != "") t2 = txt2.value;
    if (txt3.value != "") t3 = txt3.value;
    if (txt4.value != "") t4 = txt4.value;
    _txt5.value = parseInt(t1) + parseInt(t2) + parseInt(t3) + parseInt(t4) ;
}
</script>
<div> 

<asp:TextBox ID="TextBox2" runat="server" Onchange="return sumCalc();"></asp:TextBox>

<div> 

<asp:TextBox ID="TextBox3" runat="server" Onchange="return sumCalc();"></asp:TextBox>

<div> 

<asp:TextBox ID="TextBox4" runat="server" Onchange="return sumCalc();"></asp:TextBox>

<div> Total:<asp:TextBox ID="TextBox5" runat="server"  ></asp:TextBox></div>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In ASP.Net Code

<div>
        <asp:TextBox ID="TextBox1" runat="server" onchange="sumCalc()"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" onchange="sumCalc()"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server" onchange="sumCalc()"></asp:TextBox>
        <asp:TextBox ID="TextBox4" runat="server" onchange="sumCalc()"></asp:TextBox>
        
        <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
     </div>

In Javascript

<script type="text/javascript">
        function sumCalc()
        {
            var _txt1 = document.getElementById("TextBox1").value;
            var _txt2 = document.getElementById("TextBox2").value;
            var _txt3 = document.getElementById("TextBox3").value;
            var _txt4 = document.getElementById("TextBox4").value;

            if (_txt1 == "")
                _txt1 = 0;
            if (_txt2 == "")
                _txt2 = 0;
            if (_txt3 == "")
                _txt3 = 0;
            if (_txt4 == "")
                _txt4 = 0;

            var total = parseInt(_txt1) + parseInt(_txt2) + parseInt(_txt3) + parseInt(_txt4);
            if (!isNaN(total)) {
                document.getElementById('TextBox5').value = total;
            }
        }
    </script>
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!