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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:30:38+00:00 2026-05-23T17:30:38+00:00

I have an Element Like <div class=control> <label>&nbsp;</label> <input type=checkbox id=1><span class=controlText>Check Box</span> <div

  • 0

I have an Element Like

<div class="control">
      <label>&nbsp;</label>
       <input type="checkbox" id="1"><span class="controlText">Check Box</span>
        <div style="display: inline;" class="delete"><sup>x</sup></div>
        <div style="display: inline;" class="properties chkbox">Properties</div>
     </div>

This element is in a form with id userForm
What I do is when the user clicks on a button it calls a function and searches all the div`s with class control and gets information about the element in that div.

 if($("#userForm").children().size() > 1){
        var controls = new Array();
        $('#userForm').find('div.control').each(function(index, Element)
            {
                if($(Element).find('input').attr('type') == "checkbox")
                {// If element is of type checkbox
                    var attributes = new Array();
                    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;
                    $.each(attributes, function(key, value) {
                        // here i need to print the array. 
                        // I need a format of the arrays like
                        //  controls[0]
                        //            =>
                        //              [type] = checkbox
                        //              [name] = chk_name_1
                        //              [required] = ture
                        //          [1] 
                        //            => .....  
                        alert( "The key is '" + key + "' and the value is '" + value + "'" );

                    }); 
                }
            });
}
  • 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-23T17:30:38+00:00Added an answer on May 23, 2026 at 5:30 pm

    Your code is nearly right, but there are some problems. On the lines where you assign values to the elements of the attributes array, you need to put the name of the elements in quotes:

    attributes["type"] = "checkbox";
    

    Otherwise, it’s looking for a variable called type, which doesn’t exist.

    Your .each loop will work fine, so you just need to print the values in whatever format you like. Note that value in the loop is an array, so to print the type, for example, you will need:

    value["type"]
    

    You are also looping through the wrong collection, so change $.each(attributes, function(key, value) { to $.each(controls, function(key, value) {

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

Sidebar

Related Questions

I have a simple div on html, something like: <div class=warning> <h3>Please make sure:</h3>
I have an element with an onclick method. I would like to activate that
I have an HTML string representing an element: '<li>text</li>' . I'd like to append
I have a span element inside a table td element. The span tag has
I have built a Custom Control Class that makes it much easier to build
I have an HTML along the following lines: <div class=hiddenClass> // this implies display:none
I have the following HTML on my page: <div id=mypanel> <span>SomeText</span> <span>SomeText2</span> <span>SomeText3</span> <span>SomeText4</span>
I have the following code: <div id=elm0 data-color=color data-size=size data-more=more>something</div> <div id=elm1>This element must
I have a some elements, roughly like this: <div> <a> <div> When a user
I have an element which appears on many pages and I would like to

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.