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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:11:49+00:00 2026-05-31T07:11:49+00:00

UPDATED CODE: Now, I have this code: <h2>Testing</h2> <input type=checkbox name=fruit1 id=id1 class=box>Banana<br /><br

  • 0

UPDATED CODE:

Now, I have this code:

<h2>Testing</h2>

<input type="checkbox"  name="fruit1" id="id1"  class="box">Banana<br /><br />
<input type="checkbox"  name="fruit2" id="id2"  class="box">Cherry<br /><br />
<input type="checkbox"  name="fruit3" id="id3"  class="box">Strawberry<br /><br />
<input type="checkbox"  name="fruit4" id="id4"  class="box">Orange<br /><br />
<input type="checkbox"  name="fruit5" id="id5"  class="box">Peach<br /><br />
<form id="myForm" action="2.php" method="post">
    <input type="submit" id="groupdelete" value="clickme"><br />
</form>     

<script src="jquery-1.7.1.js" type="text/javascript"></script>
<script>

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

});

$.post("2.php", { "names" : names }, function(data) {
    names = names.join(",");
    // do something on success
    alert(data); //if everything is working correctly should alert the var_dump here
});
});

</script>

On page 2.php I have this:

<?php
$names = explode(",",$_POST['names']);
var_dump($names);
?>

Which prints: array(1) { [0]=> string(0) “” }

What I am doing wrong???

Zoran

  • 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-31T07:11:50+00:00Added an answer on May 31, 2026 at 7:11 am

    Send an ajax request to the server

    names.push($(this).attr("id"));
    
    $('#groupdelete').on('click', function(e){
        e.preventDefault(); //stop the default form action
        var names = [];
        $('input:checked').each(function() {
            names.push($(this).attr("id"));
        });
    
        $.post("page2.php", { "names" : names }, function(data) {
            // do something on success
            alert(data); //if everything is working correctly should alert whatever page2.php echos or prints
        });
    
    });
    

    Update 1

    JS Array and PHP array are two different things and an easy way to overcome this is join

    names = names.join(","); //Join all the array with a comma nd send
    

    Later on the PHP Script, use explode() to get your array back

    $names = explode(",",$_POST['names']);
    var_dump($names);
    

    Update 2

    Make the following changes on your current code

    names = names.join(",");
    $.post("2.php", { "names" : names }, function(data) {
        alert(data); //if everything is working correctly should alert the var_dump here
    });
    

    Update 3

    I have created a fiddle, with the proper way to do it. Check it and update your codes as per.

    Update 4

    Ok, finally starting the get the picture now. Check this update.

    Basically, create a hidden element, whose value will be updated with the checked box’s id value and send it.

    Update 5

    If you want to stop a field from being submitted. You can assign disabled="disabled" to stop it from being submitted.

    Here is an updated fiddle

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

Sidebar

Related Questions

Here is the set up, (all testing code) I have a combo box on
UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
Okay I have updated my code quite a bit. I am getting a new
Okay I have updated my code a little, but I am still not exactly
Update: This turned into a blog post, with updated links and code, over at
I've recently updated to a testing distribution, which is now using GCC 4.4.3. Now
I have this code: $fp = fopen($unenc_path, w); fwrite($fp, $msg); fclose($fp); $easy_access_emails = 'person@##.com';
I don't have much experience doing unit testing. From what I learned, code should
So I have jFeed working on another site and i'm testing it right now
I've updated some code to use the Ajax Control toolkit 0911 beta and for

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.