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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:57:00+00:00 2026-06-18T10:57:00+00:00

I have several Input-Boxes that are not present on first page load. They are

  • 0

I have several Input-Boxes that are not present on first page load. They are created by JQuery via .clone().

<input type="text" class="myInputs" name="input[0]" />
<input type="text" class="myInputs" name="input[1]" />
<input id="remove" type="button" value="Remove last input">

Then I’ve a function to sum up all these fields and make an alert with the result, which is called by
a) an onchange function for the input fields (works like a charm) and
b) a “remove one of the input fields”-button that should remove one field and then call the function again.

$(document).ready( function() {
    function calculatesum() {
        var sum = 0;
        var value = 0;
        var error = false;
        var count = new Number($("input.myInputs").length);

        if(count >= 1) {
            $("input.myInputs").each(function() {
                if($.isNumeric($(this).val())) {
                    value = new Number($(this).val());
                    sum = sum + value;
                }
                else
                    error = true;
            });
        }
        if(!error)  alert(sum);
        else        alert("Error");
    }

    $('body').on('change', 'input.myInputs', function () {  
        calculatesum();
    });

    $('#remove').click(function () {
        if (confirm("Are you sure?")) {                 
            $('.myInputs:last').slideUp('slow', function () {
                $(this).remove();
            });
            calculatesum();
        }
        return false;
    });
}

Now the point is, after removing the element via the button-function, it still gets the (previously deleted) input field and its value.
How can I prevent that?

  • 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-06-18T10:57:02+00:00Added an answer on June 18, 2026 at 10:57 am

    You should use .on instead of click at the below code fragment, like this

    $('#remove').on('click', function () {
            if (confirm("Are you sure?")) {                 
                $('.myInputs:last').slideUp('slow').remove();
                calculatesum();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several different types of input that I am cloning using jQuery clone.
Hi I have several text input boxes, and i have a clear button, they
I have several datepickers tied to input fields. They are created in the usual
I have several input boxes on a page, and I want the text to
I have a form with several text boxes. The first input box is Business
I have several inputs, they are created dynamically <input style=width:100% class=fileDescription type=text name=' +
I have several input fields that are enhanced with jQuery auto-complete functionality. How to
I am using jQuery 1.4.3 I have several input that look like this: <input
I have... a dynamic populated select box several input boxes a submit button form
In my iOS app I have several UIElement s that can process user input:

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.