全选、反选

来源:互联网 发布:知乎英国梨和小苍兰 编辑:程序博客网 时间:2024/06/06 00:12
//Controller$isBldtbomFdxinbom = array();if(isset($v['sub_shipping_method']) && in_array ($v['sub_shipping_method'], Shipping_Service_ShipType::$bldtbomFdxinbom)){    $isBldtbomFdxinbom[$v['sub_shipping_method']] = $v['sub_shipping_method'] . '(' . $v['count'] . ')' . str_repeat("&nbsp;&nbsp;", 16-strlen($v['sub_shipping_method'] . '(' . $v['count'] . ')'));}$this->view->isBldtbomFdxinbom = array_reverse($isBldtbomFdxinbom,true);//Services//array_merge 合并一个或多个数组public static function indinShip() {    $indinShip = array_merge(array('AMEXP', Shipping_Service_ShipType::$newShipping, 'FKEXP'), Shipping_Service_ShipType::$bldtbomFdxinbom);    return $indinShip;}public static $bldtbomFdxinbom = array("BLDTBOM", "FDXINBOM");//Html<div style='border-top:1px solid #dedede;padding-bottom: 5px;padding-top:10px;clear:both;'>    <label style="width:85px;"><span style="display:inline-block;color:blue;">请选择运输方式</span> <input type="checkbox" onclick="selectShipClick(3)" class="checkAll2" />全选/反选</label></div><div>    <ul>        <{foreach from=$isSendToIndia key=key item=ship_tp}>        <li style="float:left;margin-left:10px;"><label><input name='ship_type[]' value='<{$key}>' onclick="selectShipClick(3)" type='checkbox' class='order_inexp'/><{$ship_tp}></label></li>        <{/foreach}>    </ul>                                        <ul>        <{foreach from=$isBldtbomFdxinbom key=k item=v}>        <li style="float:left;margin-left:10px;"><label><input name='ship_type[]' value='<{$k}>' onclick="selectShipClick(3)" type='checkbox' class='order_inexp_v'/><{$v}></label></li>        <{/foreach}>    </ul></div>//Js//格式var k = 1;$(".order_inexp_v:checked").each(function(){    selectShip+=$.trim($(this).parent().text())+"&nbsp;&nbsp;";    if (parseInt(j) == 7)    {        selectShip+= "<br>";        k = 0;    }    k++;});//反选function selectShipClick(type){    if(type==2){        $(".order_ship").attr('checked',false);        $(".checksAll").attr('checked',false);        $(".checkAll2").attr('checked',false);        $(".order_inexp").attr('checked',false);        $(".order_inexp_v").attr('checked',false);    }else if(type==3){        $(".order_ship").attr('checked',false);        $(".checksAll").attr('checked',false);        $(".ship_type_one").attr('checked',false);    }else{        $(".checkAll2").attr('checked',false);        $(".order_inexp").attr('checked',false);        $(".ship_type_one").attr('checked',false);        $(".order_inexp_v").attr('checked',false);    }}//二选一$(".checkAll2").click(function(){    $(".checkAll2").is(":checked")?$(".order_inexp").attr("checked",true):$(".order_inexp").attr("checked",false);    $(".order_inexp_v").attr("checked",false);});$(".order_inexp_v").click(function(){    if($(".order_inexp_v").is(":checked")){        $(".order_inexp").attr("checked",false);   }});$(".order_inexp").click(function(){    if($(".order_inexp").is(":checked")){       $(".order_inexp_v").attr("checked",false);   }});//传选择后的参数$(".order_inexp_v:checked").each(function(){    orderShip.push($(this).val());});var params = {"ship_type":orderShip};data:params,