jquery Gets the value of multiple checkboxes asynchronously submitted to PHP method, jquerycheckbox_php Tutorial

Source: Internet
Author: User

jquery Gets the value of multiple checkboxes asynchronously to the method that is submitted to PHP, Jquerycheckbox


This example describes how jquery gets the values of multiple checkboxes asynchronously to the PHP method. Share to everyone for your reference. The implementation method is as follows:

HTML code:

    <?= $item [' mtaccount_id ']?>  <?= $item [' account_id ']?> <?=  $item [' account_name ']?>  <?= $item [' Server ']?>  <?= $item [' Platform ']?>

My is that the data in the HTML is read from the database, in this can be understood as the following code

  • User 1
  • User 2
  • User 3
  • User 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

    $MT 4Ids =!empty ($_post[' mt4ids ')? $_post[' mt4ids ': false; $stripMt 4Ids = preg_replace ('/[\ "\[\]]/', ' ', $mt 4Ids); $MT 4IdsToArr = Explode (', ', $ Stripmt4ids), foreach ($mt 4IdsToArr as $uid) {   permission_relation::add ($uid, $gid);} $data = Array (   ' state ' = = 1,   ' msg '  = ' operation succeeded '); Echo Json_encode ($data); return false;//$gid negligible

    I hope this article is helpful to everyone's PHP programming.

    http://www.bkjia.com/PHPjc/1021083.html www.bkjia.com true http://www.bkjia.com/PHPjc/1021083.html techarticle jquery Gets the value of multiple checkboxes asynchronously to the PHP method, Jquerycheckbox This example describes how jquery gets the values of multiple checkboxes asynchronously to the PHP method. Share to everyone ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.