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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:53:02+00:00 2026-05-23T16:53:02+00:00

I am going to make an associative array of the information I am dealing

  • 0

I am going to make an associative array of the information I am dealing with. I have the following code:

var controls = {};
$('#userForm').find('div.control').each(function(index, Element)
{
    if($(Element).find('input').attr('type') == "checkbox")
    {
        var attributes = {}; // Object
        attributes["type"] = "checkbox";
        attributes["name"] = $(Element).find('.controlText').text().toLowerCase().split(" ").join("_")+"_"+$(Element).find('input').attr("id");
        attributes["required"] = $(Element).find('input').hasClass('required');
        controls[index] = attributes;
        $(controls[index]).children().each(function(){
            // How do i check the controls object each value 
            alert($(this));

          });
    }
});

I want to make an array of controls which will contain each input’s properties separately in an index like this;

controls 
   [0] =>
       [type] = checkbox
       [name] = chk_box_1
       [required] = true
   [1] =>
       [type] = checkbox
       [name] = chk_box_2
       [required] = false

…and so on similarly.

How can I populate the controls array and then see the elements in javascript and pass them to php and print the array there?

  • 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-23T16:53:03+00:00Added an answer on May 23, 2026 at 4:53 pm

    Make it an array of objects.

    var controls = [];
    $('#userForm').find('div.control').each(function (index, elm) {
        if ($(elm).find('input').attr('type') == "checkbox") {
            var attributes = {}; // Object
            attributes["type"] = "checkbox";
            attributes["name"] = $(elm).find('.controlText').text().toLowerCase().split(" ").join("_") + "_" + $(elm).find('input').attr("id");
            attributes["required"] = $(elm).find('input').hasClass('required');
            controls.push(attributes);
        }
    });
    

    Now access it like this.

    for(var i = 0; i < controls.length; i++){
        //alert(controls[i].name);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

C++0x is going to make the following code and similar code ill-formed, because it
I am going to make a GUI that will have dynamically created sets of
I am going to make a simple Alarm Clock, I have user interface and
I have a for cycle that iterates over an associative array. foreach entry i
I have the following line of code to create object to access to a
this problem is going to make me bald. Save my hair plz. i have
I want to create an associative array: var aa = {} // Equivalent to
Im going to make simple game with fallowing architecture: Initialization OpenWindowAndGraphics while(game_not_end) { ReadEvents
I'm probably going to make myself look like a fool with my horrible scripting
I am going to make my project from Visual C#(Visual Studio 2010).. So i

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.