通過jQury進行大量刪除問題(PHP)

來源:互聯網
上載者:User

標籤:asc   check   elements   選中   oca   info   ima   var   .ajax   

最重要的是要在其中給value賦值為當前id,通過name查詢到id值

JS代碼:

<script type="text/javascript">

function shanchu() {

var obj = document.getElementsByName(‘GroupAll‘);
var duoxuan = ‘‘;
for (var i = 0; i < obj.length; i++) {
if (obj[i].checked) {
duoxuan = obj[i].value + ‘,‘;//如果選中,將value添加到變數duoxuan中
// alert(duoxuan);
}
}
if (duoxuan.length < 1) {
alert(‘請至少選擇一項!‘);
return 0;
} else {
if (!(confirm(‘是否確定刪除?‘))) {
return false;
}

$.ajax({
url: ‘{:U("Home/Stock/shanchu")}‘,
type: ‘post‘,
//dataType: ‘text‘,
data: {"duoxuan": duoxuan},
success: function (data) {
if (data == "Y") {
alert("刪除成功!");
window.location.href = "/Home/Stock/index";
}
},
error: function () {
alert("刪除失敗!");
}
});
}

後台代碼:

public function shanchu() {
$id = $_POST[‘duoxuan‘];
$whe[‘id‘] = array(‘in‘, $id);
$mop = M("goods_warehouse");
$info = $mop->where($whe)->select();
if ($info) {
$where[‘id‘] = array(‘in‘, $id);
$mod = M("goods_warehouse");
if ($mod->where($where)->delete()) {
$data = "Y";
}
} else {
$data = "N";
}
$this->ajaxReturn($data);
}

通過jQury進行大量刪除問題(PHP)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.