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

  • Home
  • SEARCH
  • 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 9005361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:07:28+00:00 2026-06-16T01:07:28+00:00

I am counting the number of inputs on the current document that have value.

  • 0

I am counting the number of inputs on the current document that have value. It works fine, except for when I have dynamically added more inputs. I can’t get there values.

For example I may have

<input id="participant-1"/>
<input id="participant-2"/>
...

Dynamically created after button click

<input id="participant-15" />

I’ll get the value of each one in a for loop like

for(var i =1 ; i <25; i++)
{
  ...$('input#participant-' + i).val();
}

Now when I run a for loop to check the value of each one of these inputs it only gets the values of the inputs that weren’t dynamically created. I have looked at the other questions on here and I still can’t see how to apply something like .on() to what I am trying to accomplish.

NEW FOLLOW UP QUESTION
ok, now I think this is where I need more clarification concerning how to use the .on.

I have a jsfiddle here: JsFiddle example

where I create new elements and on blur of all text boxes I would like to calculate how many of the elements have value and log it. Now it currently will respond from blur event with elements who were static. It doesn’t work for dynamically created elements

  • 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-16T01:07:30+00:00Added an answer on June 16, 2026 at 1:07 am

    Give it a common class:

    <input class="textbox" id="participant-1"/>
    <input class="textbox" id="participant-2"/>
    

    And get it like:

    var values = [];
    $('.textbox').each(function(){
        values.push($(this).val());
    });
    console.log(values)
    

    And to answer the edit:

    The Syntax should be : $(container_selector).on(event_type, target_selector, callback)

    JSFiddle Demo

    $('.name').on('blur', 'input', calculate_total);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a program that is counting the number of lines in a
Does anyone know how to or have some code on counting the number of
When the user inputs number m = 0, the program will never stop counting.
There seems to have many question asked similar on counting number of element already
An SQL aggregate function counting number of name enteries in DB. string cnnStr =
List the SHORTEST POSSIBLE CODE (counting number of instructions) for making x, y, and
Is their any way of counting number of django logins? The last_login field of
Joel mentioned counting the number of set bits in a byte as a programming
I've seen the numerous questions about counting the number of set bits in an
What would be the most efficient way of counting the number of times a

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.