尊龙凯时人生就是搏

thinkphpÔõÑùʵÏÖÈ«Ñ¡ºÍɾ³ý¹¦Ð§

Ò»¡¢È«Ñ¡¹¦Ð§ÊµÏÖ

1.ÔÚÊÓͼÎļþÖÐ £¬ÎÒÃÇÐèÒªÌí¼ÓÒ»¸öÈ«Ñ¡µÄ°´Å¥ £¬ÀàËÆÓÚÏÂÃæÕâÑùµÄ´úÂ룺

<input type="checkbox" name="chkall" onclick="check_all(this)">

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬check_all()º¯ÊýµÄ×÷ÓÃÊÇÈ«Ñ¡»ò×÷·ÏÈ«Ñ¡£º

function check_all(obj){
   $(':checkbox').prop('checked', $(obj).prop('checked'));
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâÀï £¬Óõ½ÁËjQueryµÄÑ¡ÔñÆ÷Ñ¡ÔñËùÓеÄcheckbox²¢Ê¹ÓÃprop()ÒªÁìÉèÖÃÆächeckedÊôÐÔ¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

2.ÒÔThinkPHPΪÀý £¬ÎÒÃǼÙÉèÒѾ­»ñÈ¡µ½ÁËÐèÒª¾ÙÐÐÈ«Ñ¡µÄÊý¾Ý £¬²¢½«Æäת´ïµ½ÊÓͼҳÃæÖÐ £¬´ËʱÎÒÃÇÐèҪʹÓÃforÑ­»·±éÀúÿ¸öÊý¾Ý £¬²¢ÎªÆäÌí¼ÓcheckboxºÍID £¬´úÂëÈçÏ£º

<?php foreach($list as $data):?>
<tr>
    <td><input type="checkbox" name="ckb[]"  value="<?php echo $data['id'];?>" ></td>
    <td><?php echo $data['title'];?></td>
</tr>
<?php endforeach;?>

µÇ¼ºó¸´ÖÆ

ÔÚÕâÀï £¬ÎªÁËÀû±ã²Ù×÷ £¬Ê¹ÓÃÁËÊý×éת´ïcheckboxµÄÖµ £¬checkboxµÄÃû³ÆΪckb[] £¬Æä¶ÔÓ¦µÄvalueΪ¸ÃÐÐÊý¾ÝµÄIDÖµ¡£

3.´ËʱÎÒÃÇÖ»ÐèÒªÔÚÌá½»±íµ¥µÄʱ¼ä»ñÈ¡µ½ËùÓÐÑ¡ÖеÄcheckbox²¢½«Æä¶ÔÓ¦µÄÖµ×éºÏ³ÉÒ»¸öеÄÊý×é £¬¾Í¿ÉÒÔʵÏÖÈ«Ñ¡µÄ¹¦Ð§ÁË¡£ÏêϸʵÏÖ´úÂëÈçÏ£º

public function all(){
   $ids = input('post.ckb/a');
   if(empty($ids)){
       return $this->error('ÇëѡժҪɾ³ýµÄÊý¾Ý£¡');
   }
   $ids = implode(',',$ids);
   $where['id'] = array('in',$ids);
   $result = db('table')->where($where)->delete();
   if($result){
       return $this->success('ɾ³ýÀֳɣ¡');
   }else{
       return $this->error('ɾ³ýʧ°Ü£¡');
   }
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâÀï £¬input(‘post.ckb/a’)ÓÃÓÚ»ñÈ¡Ìá½»±íµ¥Ê±×ª´ïµÄËùÓÐcheckboxµÄÖµ £¬Ê¹ÓÃimplode()ÒªÁ콫ÆäÅþÁ¬³É×Ö·û´® £¬²¢½«ÆäÓÃÓÚÅÌÎÊÊý¾Ý¿âÖеÄÊý¾Ý¡£

¶þ¡¢ÅúÁ¿É¾³ý¹¦Ð§ÊµÏÖ

ʵÏÖÅúÁ¿É¾³ý¹¦Ð§ÐèҪ͎áÇ°ÃæµÄÈ«Ñ¡¹¦Ð§ £¬Ïêϸ°ì·¨ÈçÏ£º

1.Ê×ÏÈ £¬Óû§ÐèҪѡÖÐÐèҪɾ³ýµÄÊý¾Ý £¬È»ºóµã»÷ɾ³ý°´Å¥£¨»òÆäËû×Ô½ç˵°´Å¥£© £¬ÕâʱÐèÒª»ñÈ¡Ñ¡ÖеÄÊý¾Ý²¢¶ÔÆä¾ÙÐÐɾ³ý²Ù×÷¡£

2.ΪÁËÀû±ã²Ù×÷ £¬ÎÒÃÇ¿ÉÒÔ½«ËùÓÐÑ¡ÖеÄÊý¾ÝIDÖµºÏ²¢³ÉÒ»¸ö×Ö·û´®£¨ÒÔÓ¢ÎĶººÅÍÑÀ룩 £¬È»ºó½«Æäת´ïµ½ÏÂÒ»¸ö´¦Àíº¯ÊýÖС£

3.ʹÓÃwhere()º¯Êý½«É¾³ýÌõ¼þÉèÖÃΪid in (ids)£¨ÆäÖÐ £¬idsΪËùÓÐҪɾ³ýÊý¾ÝµÄID£© £¬È»ºóʹÓÃdelete()º¯Êýɾ³ýÖª×ãÌõ¼þµÄÊý¾Ý¼´¿É¡£

ÏêϸʵÏÖ´úÂëÈçÏ£º

public function delete(){
   $ids = input('post.ids/s','');
   if(empty($ids)){
       return $this->error('ÇëѡժҪɾ³ýµÄÊý¾Ý£¡');
   }
   $where['id'] = array('in',$ids);
   $result = db('table')->where($where)->delete();
   if($result){
       return $this->success('ɾ³ýÀֳɣ¡');
   }else{
       return $this->error('ɾ³ýʧ°Ü£¡');
   }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇthinkphpÔõÑùʵÏÖÈ«Ñ¡ºÍɾ³ý¹¦Ð§µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ