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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:46:57+00:00 2026-05-25T00:46:57+00:00

I have this code: <input type=checkbox id=checkbox value=11> <input type=checkbox id=checkbox value=10> <div id=log></div>

  • 0

I have this code:

<input type="checkbox" id="checkbox" value="11">
<input type="checkbox" id="checkbox" value="10">

<div id="log"></div>

$("input").click(function() {
  $("#log").html( $(":checked").val() + " is checked!" );
});

If I start by checking the first checkbox, then the next, it will add: 11 is checked.

How can I do so, it takes ALL submitted checkbox values – like:
11,10, is checked.

And is it possible to extract those values with php so it looks like this:
10
11
Without the “,”

UPDATE:

$('input[type="submit"]').click(function() {
    var kolort = $('input[type="checkbox"]:checked').val(); 
    var output = $(this).text() + ", " + kolort;

  /*
  $('input[type="checkbox"]:checked').each(function(index) {
    output += $(this).text() + ", ";
  });*/

  alert(output + "is checked!");
});

I now have this. ALthough, it just prints out ONE of the values and not both. How can I do so it take values from EACH input?

  • 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-25T00:46:58+00:00Added an answer on May 25, 2026 at 12:46 am

    You can use jQuery’s .each() API:

    $('input[type="submit"]').click(function() {
      var output = '';
    
      $('input[type="checkbox"]:checked').each(function(index) {
        output += $(this).val() + ", ";
      });
    
      alert(output + "is checked!");
    });
    

    Test page: http://pastebin.com/LVuLUthB

    As for removing the commas, there will be no commas when processing in PHP. Checkboxes are sent as an array. What you want to do is:

    <input type="checkbox" name="checkbox[]" value="11">
    <input type="checkbox" name="checkbox[]" value="10">
    

    And then in the PHP:

    echo implode(', ', $_POST['checkbox']) . ' are checked!';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several like this in my HTML code: <input class=table type=checkbox name=interest[] value=finger
I have some HTML code like this: <input id=fieldname-1 name=field_name[value][1] value=1 type=checkbox /> <input
I have the following HTML code: <input type=checkbox value=1 /> <input type=checkbox value=2 />
Suppose to have a code like this: <div class=notSelected> <label>Name <input type=text name=name id=name
I have the following code: <td><input class=publish id=publish_company_ids name=publish_company_ids[] type=checkbox value=1 /></td> <td><input class=discard
Consider this simple example code: <form name=text id=frm1 method=post> <input type=checkbox name=name[] value=1000> Chk1<br>
I have the following code structure: <input type=checkbox name=some_name_1 value=some_val /> <input type=text name=input_name_1
I have this line of code for page load: if ($(input).is(':checked')) { and it
I have an input array like <input id='delete[18]' name=delete[18] value=1 type=checkbox> <input id='delete[19]' name=delete[19]
I have this simple html piece of code, whenever I click on any of

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.