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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:57:50+00:00 2026-05-30T05:57:50+00:00

I have a select list with products on clicking an add button you it

  • 0

I have a select list with products on clicking an add button you it will generate the info and display it inside input boxes that are inside a div that has an id, each time you add a product a new div is added, on registering all products I want to get the info of the input boxes for each div that is created here’s the code:
This is the one that makes the div’s and inputs

$(document).on('click', '#ap', function() {
    var desctext =  $('#descripcion option:selected').text();
    var descval = $('#descripcion option:selected').val();
    var html = 
        '<div class="productoaline">' +
        '<input type="text" class="id" name="descval" readonly="readonly" value="' + descval + '"/>' +
        '<input type="text" class="text" readonly="readonly" value="' + desctext + '"/>' +
        '<input type="text" class="text" name="cantidad" placeholder="CANTIDAD DESEADA" value=""/>' +
        '<input type="button" class="button remove" value="Quitar" />' +
        '<div>';
    $('#productosa').append(html);
});

This is the one to get values that I have so far

$(document).on('click', '#registrar', function(){
//var idp;
var cant;

// $('.productoaline').each(function(index){

$('.productoaline').each(function(index){
    //idp = $('name=["descval"]').val();
    cant = $('name=["cantidad"]').val();
    alert(index + ':' + cant);
 });

 // });

});

I only need the ones that have names how can I get only those inputs from each div. how about selecting the even index it appears that the even index are the one that I need.
Thank’s for the help! I’ve thought of using map but I have never used it any insight would be greatly appreciated

  • 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-30T05:57:51+00:00Added an answer on May 30, 2026 at 5:57 am

    A few things to note here…

    • You’re only supposed to use a certain id once in a document, if you’re using it more than once, you might want to consider using a class, or try iterating the id: “productoaline1”, “productoaline2”, etc…
    • Inside of your each loop you’re selecting #cantidad, which will naturally only give you a result the third time.
    • You should be using console.log() instead of alert() to display debug information. This will output information to your browser’s console. You access the console via something like Firefox’s Firebug, or Google Chrome’s Inspector.

    I’m not sure exactly what you’re asking, but I think you might be looking for something like this:

    $('#productoaline > input').each( function( index ){
        console.log( index, $(this).val() );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a <select> list of products that I generate with PHP. I would
I have a g:select in my view that displays a list of products: <g:form
I have a SELECT LIST MENU containing products and on this menu i use
OK So I have this list of products that are in the cart. I
I have a query that JOINs some tables to get a list of products
i have a set of radio boxes, and a select list. The radio boxes
I have a Gridview that displays a huge list of products. On Client click
I have a situation where i display a list of products for a customer.
I am trying to generate a list of Products that details the amount of
I have a select list which is being populated using the values from 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.