• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Send same name multiple checkbox values via ajax

javascriptphpjqueryajax


PHP Snippet 1:

var checked = [];
$("input[name='userpages[]']:checked").each(function ()
{
    checked.push(parseInt($(this).val()));
});

PHP Snippet 2:

var data = []

$('input[name="userpages[]"').each (function (index, element) {
    data[$(element).attr('id')] = $(element).val();
});
console.log(data);

Related Snippets

php script to delete files older than 24 hrs, deletes all files

Passing a boolean value from checkbox in Laravel form

array_key_exists(): The first argument should be either a string or an integer

Read users and passwords from a txt file

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

How do I call a php file with axios?

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Pass an image through AJAX [duplicate]

possible options to create pdf file using html elements to generate invoice in php and codeigniter

How to submit the custom form data in database in WordPress without plugin using ajax?

Laravel whole batch is cancelled if one Job fails

enroll_table three field fetch to payment form to create payment field in laravel 5.5

Laravel UUID generation

Implode array with array of glue strings

PHP - installing Xdebug on Mac with XAMPP (Unix File)

About Contact Privacy policy Terms and conditions