Jquery gets the value of multiple checkboxes and submits them to php asynchronously. jquerycheckbox. Jquery gets multiple checkbox values and asynchronously submits them to php. This document describes how jquery asynchronously submits the values of multiple checkboxes to php. I will share with you the method for jquery to obtain multiple checkbox values and submit them to php asynchronously. jquerycheckbox
This example describes how jquery asynchronously submits multiple checkbox values to php. Share it with you for your reference. The specific implementation method is as follows:
Html code:
<?=$item['mtaccount_id']?> <?=$item['account_id']?> <?=$item['account_name']?> <?=$item['server']?> <?=$item['platform']?>
My data in html is read from the database and can be understood as the following code:
User 1User 2User 3User 4
Jquery code:
Var mt4Ids = []; $ ('input [name = uid] '). each (function () {if (this. checked) {mt4Ids. push ($ (this ). val () ;}}); data = {mt4Ids: JSON. stringify (mt4Ids)}; var pUrl = "/a/manageUser.html"; $. post (pUrl, data, function (data) {if (data. state = 1) {alert (data. msg); location. href = "/h/permission.html";} else {alert ("Operation failed") ;}, 'json ');
PHP code
$ Mt4Ids =! Empty ($ _ POST ['mt4kids'])? $ _ POST ['mt4kids']: false; $ stripMt4Ids = preg_replace ('/[\ "\ [\]/','', $ mt4Ids ); $ mt4IdsToArr = explode (',', $ stripMt4Ids); foreach ($ mt4IdsToArr as $ uid) {permission_relation: add ($ uid, $ gid );} $ data = array ('state' => 1, 'MSG '=> 'Operation succeeded'); echo json_encode ($ data); return false; // $ gid can be ignored
I hope this article will help you with php programming.
Examples in this article describes how jquery asynchronously submits multiple checkbox values to php. Share it with you...