Jquery obtains the checkbox value and submits the value in post.

Source: Internet
Author: User
This article mainly introduces jquery to get the checkbox value and submit it in post mode. If you need a friend, you can refer to the following nonsense and directly provide the Code:

The Code is as follows:










<? Php
$ Data = $ _ POST ['data'];
$ Arr = json_decode ($ data );
Var_dump ($ arr );
$ A = array (1, 2, 4 );
Foreach ($ a as $ v ){
?>

<? Php
}
?>


Script
$ ('. But_delet_choice'). click (function (){
// Obtain the checkbox that is not included in the entire selection
Var $ check_boxes = $ ("input [name = 'checkbox']: checked ");
If ($ check_boxes.length <= 0 ){
Alert ('You have not checked, please check it! ');
Return;
}
Var array = new Array ();
$ Check_boxes.each (function (){
Var array_push = new Array ();
Array_push.push ($ (this). val ());
Array_push.push (2 );
Array. push (array_push );
})
$. Post (
'Test1. php ',
{
Data: JSON. stringify (array)
}
);
Return false;
});
Script

The Code is as follows:


Array (4 ){
[0] =>
Array (2 ){
[0] =>
String (1) "1"
[1] =>
Int (2)
}
[1] =>
Array (2 ){
[0] =>
String (1) "2"
[1] =>
Int (2)
}
[2] =>
Array (2 ){
[0] =>
String (1) "3"
[1] =>
Int (2)
}
[3] =>
Array (2 ){
[0] =>
String (1) "4"
[1] =>
Int (2)
}
}

This is just a simple implementation. I will give you a reference. You can freely expand it.

Related Article

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.