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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:25:57+00:00 2026-06-11T09:25:57+00:00

I am building a multi-step contact form (each step is within an article tag),

  • 0

I am building a multi-step contact form (each step is within an article tag), and I am using jQuery map() to store the labels and input values into an array, and then on the last part of the form, the information is displayed. The jQuery that stores the array is like so:

$("article:last").prev().find("a.next").on("click", function(){
    var arr = $('.form-item').map(function() {
        var lab = $('label', this).text();
        var val = $('input', this).val();
        return "<li>" + lab + " " + val + "</li>";
    }).get()

    $("article:last ul#results").append(arr.join(''))
});

This works great, but returns “undefined” for textareas and select menus, rightfully so. I need to adapt this code to work for select items and textareas. My HTML is very simple, like so:

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

<div class="form-item">
    <label>Message:</label>
    <textarea rows="2" cols="20"></textarea>
</div>
</article>

Each article represents a new section of the form. So the question is, how to I adapt my jQuery to support other form elements? Would it be a good bet to do a conditional saying, “if .form-item‘s children contains a textarea, run this code….etc.

  • 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-11T09:25:58+00:00Added an answer on June 11, 2026 at 9:25 am

    You can use :eq() selector, eq(1) selects the second child of the div tags, an input or a textarea element.

    var arr = $('.form-item').map(function() {
        var lab = $('label', this).text();
        var val = $(':eq(1)', this).val();
        return "<li>" + lab + " " + val + "</li>";
    }).get()
    

    http://jsfiddle.net/bFumx/

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

Sidebar

Related Questions

I'm building a multi-step form in rails. It's not javascript driven, so each page
I'm building a multi-step form in jQuery which updates the URL according to which
I'm building a multi-section splash page using jQuery scrollTo to navigate between sections. There's
I am building a multi-producer/single-consumer application using IPC, implemented using Boost.Interprocess . Each producer
I'm building an app based on jQuery mobile, and using the multi-page template feature
I'm building a multi-lingual website using drupal 7. Now, I'm in the process of
I'm building multi tenant application with shared table structure using Microsoft SQL Server. I
We are building an ASP.Net MVC 2 multi-tenant application on SQL Server using the
I'm building a multi-threaded service application in Delphi XE2. Each thread serves its own
So imagine I'm building a Multi User Dungeon system using a MVC web application.

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.