function GetCheckbox(){
var data=new Array();
$("input:checkbox[name='selectdel[]']").each(function (){
if($(this).attr("checked")==true){
data.push($(this).val());
}
});
if(data.length > 0){
$.post("index.php?r=member/my_cart/delall",{'selectdel[]':data}, function (data) {
if (data=='ok') {
alert('删除成功!');
location.href = "index.php?r=member/my_cart/admin";
}
});
}else{
alert("请选择要删除的选项!");
}
}
3.Action中
public function actionDelall() {
if (Yii::app()->request->isPostRequest) {
$criteria = new CDbCriteria;
$criteria->addInCondition('rec_id', $_POST['selectdel']);
Cartdb::model()->deleteAll($criteria);
if (isset(Yii::app()->request->isAjaxRequest)) {
echo 'ok';
}
else
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
}
else
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}