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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:37:32+00:00 2026-05-27T08:37:32+00:00

I am trying to get all checkboxes checked with: <script type=text/javascript> $(document).ready(function() { $(#delmsg_all).click(function()

  • 0

I am trying to get all checkboxes checked with:

<script type="text/javascript">
    $(document).ready(function()
    {
        $("#delmsg_all").click(function()               
        {
            var checked_status = this.checked;
            $("input[(name=delmsg[])]").each(function()
            {
                this.checked = checked_status;
            });
        });                 
    });

</script>

All checkboxes get checked.
form part:

<input type="checkbox" name="delmsg[]" value="<?php echo $aRows['pvID'];?>"/>

So far, so good, but…..

i expect an array with all checked values, but i dont get an array back?

code for checking what is sent by my form:

## Berichten verwijderen
// test op eigen berichten??
if(isset($_POST['todo']) AND $_POST['todo'] == 'verwijder_mijn_berichten')
{
    if(is_array($_POST['delmsg']))
        $aMeldingen[] = 'yessss';// shows text in jquery lightbox
    else
        $aErrors[] = 'test?'; // just used as testvalue
    foreach($_POST['delmsg'] AS $key => $value)
    {
        $aMeldingen[] = $key.' => '.$value;
        echo $key.' => '.$value;
    }

}

Problem:
when i use delmsg as name of the checkboxes, the jquery function works, all checkboxes become checked, but after submitting the form, no array is recognized.

when i use delmsg[] as name of my checkboxes, the jquery function does NOT check all the checkboxes, but the array is recognized well. (after i selected some checkboxes by hand)

Where does it go wrong with my thoughts?

Thanks in advance for any help!

  • 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-27T08:37:32+00:00Added an answer on May 27, 2026 at 8:37 am

    It’s a little bit problematic to use brackets in name attribute. jQuery selector engine sizzle uses it for a different purpose, so it does not recognize it directly. You have to escape it twice like \\[\\]. (From jQuery documentation) You can get your checkboxes like this: $("input[name=delmsg\\[\\]]")

    If it’s not important you can give same class to your checkboxes and then select them with class name;

    HTML/PHP

    <input type="checkbox" name="delmsg[]" class="delmsg" value="<?php echo $aRows['pvID'];?>"/>
    

    Javascript

    $(document).ready(function()
    {
        $("#delmsg_all").click(function()               
        {
            $(".delmsg").prop('checked', this.checked);
        });                 
    });
    

    By the way, if you will not do something else in each iteration, you can set checked property with just one command; .prop()

    If you don’t want to use extra class, you may get checkboxes with :checkbox selector.

    $(document).ready(function()
    {
        $("#delmsg_all").click(function()               
        {
            $(":checkbox").prop('checked', this.checked);
        });                 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to get the values of all the checked checkboxes and post those
I'm trying to get all of my checkboxes to be checked when clicking a
I am trying to get an array of checkboxes that ARE checked AND have
I'm trying to write some CoffeScript function which checks all checkboxes in a table
I am trying to get all input textboxes, radio groups, checkboxes etc. I am
iam trying to get all object's xpath's from loaded page via selenium something similar
I'm trying to get all the direct reports of a User through Active Directory,
I'm trying to get all property names / values from an Outlook item. I
I am trying to get all the rows that exist in allData but not
I'm trying to get all controls in a winform disabled at the Load event.

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.