<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
</head>
<body>
<?php
$data = $_POST['data'];
$arr = json_decode($data);
var_dump($arr);
$a = array(1,2,3,4);
foreach($a as $v){
?> <input type = "checkbox" class="checkbox" name="checkbox" value="<?=$v?>">
<?php
}
?>
<input type = "button" class="but_delet_choice" value="post">
</body>
<script>
$('.but_delet_choice').click(function(){
//获取全选之外的checkbox
var $check_boxes = $("input[name='checkbox']:checked");
if($check_boxes.length<=0){
alert('您未勾选,请勾选!');
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>
</html> 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)
}
}

jquery获取checkbox的值并post提交的更多相关文章

  1. jquery 获取checkbox 选中值并拼接字符集

    1.代码示例: var chk_value =[]; $('input[name="rewardids"]:checked').each(function(){   chk_val ...

  2. 使用jquery获取radio的值

     使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: ...

  3. jquery获取radio选中值及遍历

    使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项:1.& ...

  4. jquery如何获取checkbox的值

    jquery如何获取checkbox的值 一.总结 一句话总结:就是通过jquery获取哪些对应name的checkbox,然后找出:check(被选中的),然后通过jquery的each遍历获取这些 ...

  5. JQuery 判断checkbox是否选中,checkbox全选,获取checkbox选中值

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. jQuery获取多种input值的方法

    1 if($("input[name=item][value='val']").attr('checked')==true) //判断是否已经打勾 name即控件name属性,va ...

  7. jQuery获取checkbox选中项等操作及注意事项

    jQuery获取checkbox选中项等操作及注意事项 今天在做一个项目功能时需要显示checkbox选项来让用户进行选择,由于前端不是很熟练,所以做了一个简单的Demo,其中遇到一些小问题,特记录下 ...

  8. jQuery获取多种input值的方法(转)

    获取input的checked值是否为true: 第一种: if($("input[name=item][value='val']").attr('checked')==true) ...

  9. [转载]jquery获取元素索引值index()方法:

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

随机推荐

  1. prism4 StockTrader RI 项目分析一些体会2

    prism 对于逻辑复杂的页面,通过建立 controller实现逻辑管理 按着一般的做法就是,各模块的viewmodel import由各模块去实例化(理解有限),但是通过controller实现了 ...

  2. ie8 iframe去掉边框的属性

    <iframe src="" id="Iframe" height="200" frameborder="0" s ...

  3. freeCodeCamp:Chunky Monkey

    猴子吃香蕉可是掰成好几段来吃哦! 把一个数组arr按照指定的数组大小size分割成若干个数组块. 例如:chunk([1,2,3,4],2)=[[1,2],[3,4]]; chunk([1,2,3,4 ...

  4. C++调用C函数

    http://blog.csdn.net/imcainiao11/article/details/7369447 前言:以前见到extern "C"这样的语句,只是简单地知道跟外部 ...

  5. 开博了,hello world

    hello  world     hello  world    hello  world     hello  world   hello  world     hello  world    he ...

  6. How to: Change Sales Rep/Team via Mass Update

    /* from: https://netsuite.custhelp.com/app/answers/detail/a_id/30057/kw/reassign%20sales */ How to c ...

  7. 【转】MySQL的各种timeout

    因为最近遇到一些超时的问题,正好就把所有的timeout参数都理一遍,首先数据库里查一下看有哪些超时: root@localhost : test 12:55:50> show global v ...

  8. navicat自动备份数据

    1.打开navicat客户端,连上mysql后,双击左边你想要备份的数据库.点击"计划",再点击"新建批处理作业". 2.双击上面的可用任务,它就会到下面的列表 ...

  9. Java学习笔记 01 基本数据类型、标识符、关键字和运算符

    一.基本数据类型 基本数据类型 数据类型 内存空间(8位等于1字节) 取值范围 备注 byte 8位 -128~127   short 16位 -32768~32767   int 32位 -2147 ...

  10. padding(内边距)、margin(外边距)、border(边框)

    元素的 padding 控制元素内容 content和元素边框 border 之间的距离. 元素的外边距 margin 控制元素边框 border 和元素实际所占空间的距离,如果你将一个元素的 mar ...