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 601875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:45:44+00:00 2026-05-13T16:45:44+00:00

I’my trying to sum up the values in text boxes and place the total

  • 0

I’my trying to sum up the values in text boxes and place the total sum in a span tag. I’ve got the functions working right (sort of…). My problem is the “KEYUP” event is not working on form elements that get added after the page loads.

For example, When the page renders it displays one INPUT box where the user can enter a number. There is an “add” link that will clone the that has the INPUT box, thus allowing the user to add as many elements they want. I’m using the class attribute to tie all the input boxes together so I can sum on them using jqueries .each().

Here’s what the code is doing. if I dynamically add 3 or for text boxes the keyup event only executes on the 1st INPUT box that was originally on the page when the page rendered…but when I type values into this box, the numbers in the dynamically created input boxes get summed up as they should. So, it’s sortof working, however I want the keyup event to be triggered from the dynamic input boxes as well.

I’m using jqueries “.after()” to add the elements to the dom.

Here’s the JQUERY code:

$(document).ready(function() {

//ADD INCOME TOTALS
$('.'income_txt\').each(function() {


$(this).keyup(function(){calculateSum('income_total', 'income_txt');});
}); //end income totals

}); //end document ready

Here’s the function that is stored in a .js file

//CALCULATESUM function
function calculateSum(ele, classname) 
{
    var sum = 0;
    //iterate through each textboxes and add the values
    $("."+classname).each(function() {

        //add only if the value is number
        if(!isNaN(this.value) && this.value.length!=0) {
            sum += parseFloat(this.value);
        }

    });
    $("#"+ele).html(sum);

}

Here’s the HTML MARKUP:

<input class="income_txt" type="text" name="income_value1" id="' . $property_id . '_income_value_id1" />

Any thoughts on how to accomplish?

Thanks for the help.

  • 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-13T16:45:44+00:00Added an answer on May 13, 2026 at 4:45 pm

    When you clone the inputs, are you adding ‘true’ to the call? This will clone the events as well.

    $('.myElement').clone(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

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.