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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:21:13+00:00 2026-05-17T01:21:13+00:00

I have a quick question that I need some help with if possible. Am

  • 0

I have a quick question that I need some help with if possible. Am I able to have more than one input with the same id and loop through the values of these? Something similar to the code below:

<p>ID:<input name="check_id" type="hidden" id="check_id"  value="1"/></p>
        <p>ID:<input name="check_id" type="hidden" id="check_id"  value="2"/></p>

jQuery("#check_id").each(function(){
var check_data = jQuery(this).val();
alert(check_data); 
});

Thanks

Paul

  • 1 1 Answer
  • 1 View
  • 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-17T01:21:13+00:00Added an answer on May 17, 2026 at 1:21 am

    No. IDs must be unique. You will likely only select the first.

    You could possibly do something like this, though it is less efficient:

    jQuery("input[id=check_id]").each(function(){
        var check_data = jQuery(this).val();
        alert(check_data); 
    });
    

    But if you’re going to do that, you might as well fix your IDs to be unique, and select by the name attribute.

    jQuery("input[name=check_id]").each(function(){
        var check_data = jQuery(this).val();
        alert(check_data); 
    });
    

    If all the <input> elements you want are contained in a container, you could speed things up by specifying that container.

    jQuery("#myContainer input[name=check_id]").each(function(){
        var check_data = jQuery(this).val();
        alert(check_data); 
    });
    

    This code example presumes there is a common ancestor with the ID myContainer.


    EDIT: With regard to your question in the comment below, return false; inside an .each() loop only exits the loop. You could however set a flag that will tell the subsequent code whether or not to execute.

    Something like this:

    var shouldContinue = true;
    
    jQuery("#myContainer input[name=check_id]").each(function(){
        var check_data = jQuery(this).val();
        if( someCondition ) {
            shouldContinue = false; // signal to not execute subsequent code
            return false;  // Halt the loop
        }
    });
    
    if( shouldContinue ) {
         // execute code if shouldContinue is true
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A quick technical question- I have two queries that output some of the same
Okay, I am stumped on this one and need some quick help. I have
Quick question, I have some scripts that only need to be run on some
Quick question about include/requre_once . I have some code that is common to a
I have a quick question that I can't seem to find online. I am
I have a quick question here. I know that the cakePHP find('first') function returns
I have a question that should be quick and easy for you guys to
just a question that needs a quick answer, I have a Action, lets say,
Quick question... I have a query that checks for duplicates that looks like this:
Quick question. I have an app that use a native DLL through PInvoke, this

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.