Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6586779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:50:04+00:00 2026-05-25T16:50:04+00:00

I am new to client-side scripting. My problem is I’ve got a lot of

  • 0

I am new to client-side scripting. My problem is I’ve got a lot of textboxes and I want them to auto-calculate, but so far nothing works. Is there something wrong on my script?

function totaltraininghour()
{
var totalhour1=0;
var a1= parseInt(document.getElementById("a1").value);
var b1= parseInt(document.getElementById("b1").value);
var c1= parseInt(document.getElementById("c1").value);
var d1= parseInt(document.getElementById("d1").value);

var totalhour2=0;
var a2= parseInt(document.getElementById("a2").value);
var b2= parseInt(document.getElementById("b2").value);
var c2= parseInt(document.getElementById("c2").value);
var d2= parseInt(document.getElementById("d2").value);

var totalhour3=0;
var a3= parseInt(document.getElementById("a3").value);
var b3= parseInt(document.getElementById("b3").value);
var c3= parseInt(document.getElementById("c3").value);
var d3= parseInt(document.getElementById("d3").value);
var totaltraining=0;

if (a1 >=0)
{
totalhour1 = totalhour1 + a1
}
if (b1>=0)
{
totalhour1 = totalhour1+ b1
}
if (c1>=0)
{
totalhour1 = totalhour1+ c1
}
if (d1>=0)
{
totalhour1 = totalhour1+ d1
}
document.getElementById("txttotalhour1").value = totalhour1

if (a2 >=0)
{
totalhour2 = totalhour2 + a2
}
if (b2>=0)
{
totalhour2 = totalhour2+ b2
}
if (c2>=0)
{
totalhour2 = totalhour2+ c2
}
if (d2>=0)
{
totalhour2 = totalhour2+ d2
}
document.getElementById("txttotalhour2").value = totalhour2

if (a3 >=0)
{
totalhour3 = totalhour2 + a3
}
if (b3>=0) 
{
totalhour3 = totalhour2+ b3
 }
if (c3>=0)
{
totalhour3 = totalhour2+ c3
}
if (d3>=0)
{
totalhour3 = totalhour2+ d3
}
document.getElementById("txttotalhour3").value = totalhour3

totaltraining = totalhour1 + totalhour2 + totalhour3
document.getElementById("txttotaltraininghours").value = totaltraining
 </script>

<asp:TextBox ID="a2" runat="server" Width="100px" onkeyup="totaltraininghour
();"></asp:TextBox> And so on..
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:50:05+00:00Added an answer on May 25, 2026 at 4:50 pm

    Make sure your IDs are what you think they are. If the controls are within a naming container, the IDs will be mangled. To get around it, have ASP.NET insert the ClientID, like this:

    var a1= parseInt(document.getElementById("<%= a1.ClientID %>").value);
    

    Note, unless you fiddle with your web server’s settings, this will only work for scripts within .aspx files, not external .js files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) {
Is it possible to use the new client side validation features of asp.net MVC
I am very new to Silverlight development. I understand that this is client side
I am starting a new client/server project at work and I want to start
I tried urllib{2}, pycurl and I'm looking at twisted's new http client. But: I
How to define client-side logic in new ASP.NET validator (not CustomValidator). Can you point
I have a question about optimization, but more on the browser/client side. I am
1) In the following example client-side TransactionScope TS1 timeouts. But unless TS1 calls Complete()
I have a problem. Client side code <html> <body onload=fun()> <script src=C:\cygwin\usr\local\lib\node\.npm\socket.io\0.6.16\package\support\socket.io-client\socket.io.js></script> <script> function
I'm relatively new to client-side programming coming from the PHP/MySQL environment. I understand the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.