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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:40:17+00:00 2026-06-11T04:40:17+00:00

I created a form, and I want to use jquery to store the labels

  • 0

I created a form, and I want to use jquery to store the labels and the user inputted input value into an array. At the bottom of the form, there is a next button instead of submit. When the user presses next, they should see a summary of all of the labels and their input. The HTML is like this:

<div class="form-item">
    <label>Zip Code:</label>
    <input type="text" />
</div>

<div class="form-item">
    <label>Address:</label>
    <input type="text" />
</div>

I believe the best way to go about this is to loop thorugh each div.form-item using each() like so:

$(".form-item").each(function(){
     var label = $(this).find('label').text(); 
     var input = $(this).find('input').val();
});

Im not sure how to go about collecting multiple chunks of form items using unique variables. I want this to be completely dynamic, so regardless of how many form fields there are, it will work. DO I store them in an array? What is the best way to go about this?

  • 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-11T04:40:19+00:00Added an answer on June 11, 2026 at 4:40 am

    You can use map method, also note that your class selector is not correct, you have missed a ..

    var arr = $('.form-item').map(function() {
                   var lab = $('label', this).text();
                   var val = $('input', this).val();
                   return lab + val;
              }).get()
    

    http://jsfiddle.net/b5Z6C/2/

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

Sidebar

Related Questions

I want to store data in string form to MySQL. I have created the
I want to use jQuery .append to insert a div into an another parent
If I have created an order form, and want to allow the user to
I Use jQuery Dialog to display a details form when creating a new user.
I've created a validation jQuery widget to validate form fields. I want to be
I want to use jQuery UI dialog box to open a form dialog where
I am new to Qt I created my first form and I want to
I have a textbox in a form that I created. I want to add
I want to create a form in which if the User presses Enter the
I want to use jquery to create a request to a controller action posting

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.