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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:18:18+00:00 2026-05-24T16:18:18+00:00

I want to iterate through a a set of input nested into groups and

  • 0

I want to iterate through a a set of input nested into groups and sections,
with the goal of performaing validation within each group and section

<script src="jquery/jquery.js"></script>

<div  id="groupA" class="preGroups">

    <div id="section-A1">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>

    <div id="section-A2">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>

    <div id="section-A3">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>

    <div id="section-A4">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>
</div>

<div  id="groupB" class="preGroups">

    <div id="section-B1">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>

    <div id="section-B2">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>

    <div id="section-B3">
    <input name="SRPR1"  type="text">
    <input name="SRPR2"  type="text">
    </div>
    </div>
<script>    

// capture all groups
groups = $('div#[id^=group]'); 
console.log(groups);

// iterate through each group in groups
$.each(groups, function(key, group) {
    console.log(group);

    // iterate through each section in group 
    sections = $('div#[id^=section]'); 
    $.each(sections, function(key, section) {
        console.log(section);

        // iterate inputs in each group
        // more code goes here
        /// console.log(input.name + " " +  input.value);       
    });
});
  • 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-24T16:18:18+00:00Added an answer on May 24, 2026 at 4:18 pm

    Looks like you might need sections = $(group).find('div#[id^=section]'); instead of sections = $('div#[id^=section]');

    EDIT

    complete code here:

    groups = $('div[id^="group"]'); 
    //console.log(groups);
    
    // iterate through each group in groups
    $.each(groups, function(key, group) {
        //console.log(group);
    
        // iterate through each section in group 
        sections = $(group).find('div[id^="section"]'); 
        $.each(sections, function(key, section) {
            //console.log(section);
            var inputs = $(section).find("input");
            // iterate inputs in each group
            // more code goes here
            inputs.each(function(){
                console.log(this.name + " " +  this.value);
            })
            /// console.log(input.name + " " +  input.value);       
        });
    });
    

    Demo

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

Sidebar

Related Questions

I want to iterate through each character in a character set (primarily US-ASCII and
I want to iterate through a set of specific values. Simple example below program
I want to iterate through a table/view and then kick off some process (e.g.
I want to iterate through all 5 character combinations of 0-9, a-z. I worked
At my template, I want to iterate through all form errors, including the ones
I have a FormCollection and I just want to only iterate through the keys
So I want to iterate for each character in a string. So I thought:
I want to iterate through a list of files without caring about what characters
I have a generator for a large set of items. I want to iterate
I've got an array of words I want to iterate through on a page,

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.