删除复选框选中的数据,不管选中多少,传过去的值只有一个,请哪里的问题
<table width="49%" cellspacing="1" bgcolor="#0093C4" id='demotable1'>
<thead>
<tr>
<th width="3%"><INPUT name="chkAll" id="chkAll" title="全选" onClick="ChkAllClick('delivery[]','chkAll')" type="checkbox" /></th>
<th width="8%" class="STYLE3">Item Code</th>
<th width="12%" class="STYLE3">SKU</th>
<th width="15%" class="STYLE3">ASIN</th>
<th width="21%" class="STYLE3">Description</th>
<th width="12%" class="STYLE3">Type</th>
<th width="9%" class="STYLE3">Delivery Areas</th>
<th width="10%" class="STYLE3">Account</th>
<th width="10%" class="STYLE3">FNSKU</th>
</tr>
</thead>
<tbody>
<?PHP
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<tr>
<td><input type="checkbox" name="delivery[]" value="<?PHP echo $row['id']; ?>" /></td>
<td><?PHP echo $row['item_code'] ?></td>
<td><?PHP echo $row['sku'] ?></td>
<td><?PHP echo $row['asin'] ?></td>
function delClick(){
var val = $('input:checked').val();
window.location.href="sku_change.php?action=del&delivery="+val;
}
<input type="button" class="btn" id="add_btn" value="新 增" />
<input name="button" type="button" class="btn" onclick="delClick()" value="删 除" />
case 'del' : //删除
$id=$_GET["delivery"];
$SQL = "delete from `sku_rule` where id in($id)";
$result = mysql_query($SQL);
if (mysql_affected_rows($conn) != 1){
echo "<script>alert('删除失败!');location.href='sku_comparison.php';</script>";
} else {
echo "<script>alert('删除成功!');location.href='sku_comparison.php';</script>";
}
break;
[解决办法]
function delClick(){
var val = $('input:checked').val();
alert(val);//看看是什么?
window.location.href="sku_change.php?action=del&delivery="+val;
}
[解决办法]
就按你那个写法,不是一个才怪呢。
function a(){
var ar=[];
$(input:checked).each(function(){
ar.push($(this).val());
});
alert(ar);
}