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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:48:47+00:00 2026-06-01T08:48:47+00:00

I’m trying to iterate a bunch of SELECT OPTION html drop-down fields and from

  • 0

I’m trying to iterate a bunch of SELECT OPTION html drop-down fields and from the ones that are NOT empty, take the values and add a hidden field for a PAYPAL shopping cart.

My problem is that for some reason, the variable “curitem” is not passed inside the each function and I can’t add the hidden field like they should. All I get is “NaN” or “undefined”.

What PAYPAL expects is: item_name_1, item_name_2, etc. All numbers must iterate by +1.

How can I do this?

Thanks a bunch in advance

var curitem;

$.each($("select"), function(index, item) {

    var attname = $(this).attr("name");
    var nom = $(this).attr("data-nom");
    var prix = $(this).attr("data-val");
    var partname = attname.substring(0, 1);
    var qte = $(this).val();

    // i want all my <select option> items that the NAME start with "q" AND have a value selected
    if (partname == "q" && isNaN(qte) == false && qte > 0) {

        // item name
        var inp2 = document.createElement("input");
        inp2.setAttribute("type", "hidden");
        inp2.setAttribute("id", "item_name_"+curitem);
        inp2.setAttribute("name", "item_name_"+curitem);
        inp2.setAttribute("value", nom);

        // amount
        var inp3 = document.createElement("input");
        inp3.setAttribute("type", "hidden");
        inp3.setAttribute("id", "amount_"+curitem);
        inp3.setAttribute("name", "amount_"+curitem);
        inp3.setAttribute("value", prix);

        // qty
        var inp4 = document.createElement("input");
        inp4.setAttribute("type", "hidden");
        inp4.setAttribute("id", "quantity_"+curitem);
        inp4.setAttribute("name", "quantity_"+curitem);
        inp4.setAttribute("value", qte);

        // add hidden fields to form
        document.getElementById('payPalForm').appendChild(inp2);
        document.getElementById('payPalForm').appendChild(inp3);
        document.getElementById('payPalForm').appendChild(inp4);


        // item number
        curitem = curitem + 1;
    }
});
  • 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-01T08:48:48+00:00Added an answer on June 1, 2026 at 8:48 am

    I think you have to initialize curitem variable.

    var curitem = 1;

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am trying to understand how to use SyndicationItem to display feed which is

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.