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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:34:23+00:00 2026-05-31T08:34:23+00:00

Hi I have the following page: <input type=checkbox name=fruit1 id=1 class=box>Banana<br /><br /> <input

  • 0

Hi I have the following page:

<input type="checkbox"  name="fruit1" id="1"  class="box">Banana<br /><br />
<input type="checkbox"  name="fruit2" id="2"  class="box">Cherry<br /><br />
<input type="checkbox"  name="fruit3" id="3"  class="box">Strawberry<br /><br />
<input type="checkbox"  name="fruit4" id="4"  class="box">Orange<br /><br />
<input type="checkbox"  name="fruit5" id="5"  class="box">Peach<br /><br />
<input type="button" id="groupdelete" value="clickme"><br />

 $(document).ready(function(){

$('#groupdelete').on('click', function(){
  var names = [];
   $('input:checked').each(function() {

       names.push($('input:checked').attr("name") + $('input:checked').attr('id'));

 });
   console.log(names); 
})

})

What I am trying to do is the following:

To add the checked checkboxes in the array. And after that, I would like to be able to pass the value in php variable.

When I excecute the code now, I am getting result like this:

[“fruit22”, “fruit22”, “fruit22”]

Any help will be deeply appreciated.

Regards, Zoreli

  • 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-31T08:34:25+00:00Added an answer on May 31, 2026 at 8:34 am

    You need to use this rather than 'input:checked' inside the .each() function to refer to the current element in the set being examined. If you re-use the selector you’re getting the set again, then only ever getting the attributes from the first element in the set.

    $('input:checked').each(function() {
        names.push($(this).attr("name") + this.id);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an html page, I have checkboxes like following: <input name=serviceareas type=checkbox id=cb1 value=1>
I have the following HTML on my web page: <input id=htmlEdit type=checkbox/> Once the
I have following checkbox arrays in html form <label><input name=columns[] type=checkbox value=pname />Property Name</label>
I have the following html button <td><form id=form2 name=form2 method=post onclick=../cgi-bin/py/GuestBookEntry.py> <input type=submit name=gBookSrib
I have a checkbox with the following code: <input type=checkbox id=check onclick=function(this); checked=checked />
I have the following page: <div style=display: inline> <input type=button id=txt value=Add TextBox style=
I have the following in my page, ready to: <div id=result></div> <script id=some-template type=text/x-handlebars-template>
What I am trying to do is following: I have an input type button
I have the following XML input file: <mappings> <mapping> <key>6718</key> <value attribute=content_type>Info Page</value> </mapping>
I have the following page with a black canvas inside of it: There, the

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.