全选,反选,获取值ajax提交

时间:2024-07-13 15:05:50

//必须先加载jquery

//加载 弹出框插件 artdialog          http://www.planeart.cn/demo/artDialog/

/****全选反选*开始**/

$(document).ready(function(){   
  $("input[name=checked_all]").click(function(){        
     var check_status = $(this).attr('checked');     
     if(check_status == "checked"){
       $(".single_status").attr("checked","checked");
     }
     if(check_status == undefined){
       $(".single_status").removeAttr("checked");
     }
   }) 
 });

/****全选反选*结束**/

function export_checked_tmp(){              
   var checked_tmp =$("input[name='export[]'][checked]");      //获取选中的值  开始
   var tmp_arr = new Array();
   $.each(checked_tmp,function(i,n){
    tmp_arr[i] = n.value
     //alert(n.value)
   })  

  if(tmp_arr.length==0){                      //如果有选中的值,提示信息
       art.dialog({
          time: 2,
          content: "请选择分配词条"
       });
     return false;        
   }

                        
  var dialog = art.dialog({id: 'N3690',title:false});          //获取完之后,ajax传参
  $.ajax({
       type: "post",
       url: "<?php echo base_url('index.php/task/create')?>",
       data: {'foo':tmp_arr,"type":"inve"},
       success: function(msg){
         dialog.content(msg);
       }
    });    
 }

<input type="checkbox" class="fl" style="margin:8px" name="checked_all" />

<input name="export[]" type ="checkbox" value="" class="single_status">

<input name="export[]" type ="checkbox" value="" class="single_status">