<div class="headbar">
<div class="position"><span>商品</span><span>></span><span>商品管理</span><span>></span><span>商品列表</span></div>
<div class="operating">
<a href="javascript:void(0)">
<button id="check_all">全选</button>
</a>
<a href="javascript:void(0)">
<button id="Invert">反选</button>
</a>
<a href="javascript:void(0)">
<button id="check_No">全不选</button>
</a>
<a href="javascript:void(0)">
<button id="del_all">批量删除</button>
</a>
</div>
<div class="field">
<table class="list_table">
<colgroup>
<col width="40px" />
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th>选择</th>
<th>商品ID</th>
<th>商品名称</th>
<th>销售价</th>
<th>库存</th>
<th>操作</th>
</tr>
</thead>
</table>
</div>
</div>
<form action="" method="post" name="orderForm">
<div class="content">
<table class="list_table">
<colgroup>
<col width="40px" />
<col />
<col />
<col />
</colgroup>
<tbody>
{query: name=test}
{if:$item['is_del'] == 0}
<tr vid="{$item['id']}">
<td><input type='checkbox' name='id[]' value='{$item['id']}' /></td>
<td>{$item['id']}</td>
<td>{$item['name']}</td>
<td><a href="javascript:void(0)" class='price'>{$item['price']}</a></td>
<td>{$item['stock']}</td>
<td>
<a href='{url:/tools/ad_position_edit/id/$item[id]}'><img class="operator" src="{skin:images/admin/icon_check.gif}" alt="获取广告位代码" title="获取广告位代码" /></a>
<a href='javascript:void(0)' οnclick="delModel({link:'{url:/tools/ad_position_del/id/$item[id]}'});"><img class="operator" src="{skin:images/admin/icon_del.gif}" alt="删除" +title="删除" /></a>
</td>
</tr>
{/if}
{/query}
</tbody>
</table>
</div>
</form>
<script>
//全选
$('#check_all').click(function(){
$("input[name = 'id[]']").each(function(){
this.checked = true;
});
});
//全不选
$('#Invert').click(function(){
$("input[name = 'id[]']").each(function(){
this.checked = false;
});
});
//反选
$('#check_No').click(function(){
$("input[name = 'id[]']").each(function(){
if(this.checked == true){
this.checked = false;
}else{
this.checked = true;
}
});
});
//批量删除
$('#del_all').click(function(){
//存放选中ID的值
var arrUserid = " ";
$("input[name = 'id[]']").each(function() {
if (this.checked == true)
{
arrUserid += $(this).val() + ",";
}
});
$.get("{url:/test/del_all}",{id:arrUserid},function(data){
// alert(data);
if(data == 1)
{
$("input[name='id[]']").each(function()
{
if(this.checked == true)
{
$(this).parents('tr').remove();
}
});
alert('删除成功');
}
else
{
alert('删除失败');
}
});
});
//即点即改
$(document).on('click','.price',function(){
var price = $(this).html();
$(this).parent().html('<input type="text" name="money" value=" '+price+' "/>');
})
$(document).on('blur','input[name = "money"]',function(){
var price = $(this).val();
var vid = $(this).parent().parent().attr('vid');
var obj = $(this);
$.get("{url:/test/update}",{'id':vid,'price':price},function(data){
if(data == 1){
obj.parent().html('<a href="javascript:void(0)" class="price">'+price+'</a>');
alert('修改成功');
}else{
obj.parent().html('<a href="javascript:void(0)" class="price">'+price+'</a>');
alert('修改失败');
}
})
})
</script>
javascript的全选,反选,全不选,即点即改,批量删除
最新推荐文章于 2022-03-27 21:24:31 发布
前台页面