Home > Web Front-end > JS Tutorial > jquery gets the value of the checkbox and submits it_jquery

jquery gets the value of the checkbox and submits it_jquery

WBOY
Release: 2016-05-16 16:20:06
Original
1200 people have browsed it

Without further ado, let’s just give you the code:

Copy code The code is as follows:








$data = $_POST['data'];
$arr = json_decode($data);
var_dump($arr);
$a = array(1,2,3,4);
foreach($a as $v){
?>

}
?>


<script><br> $('.but_delet_choice').click(function(){<br>                            //Get checkboxes other than all selections<br>         var $check_boxes = $("input[name='checkbox']:checked");<br>             if($check_boxes.length<=0){<br /> alert('You have not checked, please check!');<br />              return;<br /> }<br />          var array = new Array();<br />           $check_boxes.each(function(){<br />             var array_push = new Array();<br />               array_push.push($(this).val());<br />               array_push.push(2);<br />               array.push(array_push);<br />          })<br />          $.post(<br />               'test1.php',<br />                 {<br />                  data: JSON.stringify(array)<br />             }<br /> );<br />          return false;<br /> });<br /> </script>

Copy code 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 to give you a reference. Friends can expand freely.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template