我在输入中使用相同的名称循环我希望用户禁用 javascript,该过程仍然发生
<?php
$first = 1;
$id = array('id' => 'addcart');
foreach($data['info'] as $row):
$first++;
echo form_open('store/addcart/',$id); ?>
<td width="11%" align="center">
<span style="font-weight:bold;"><A href="<?=base_url().'store/products/'.$row['pcode'];?>" class="linkleft"><?=$row['pname'];?></a></span>
<BR><SPAN class=pdesc><A href="<?=base_url().'store/products/'.$row['pcode'];?>"> Xem Chi tiết</a></SPAN>
<BR>Giá: <span><?=$row['pprice'];?></span>
<input type="hidden" name="id" value="<?=$row['pcode'];?>"/>
<input type="hidden" name="qty" value="1"/>
<input type="hidden" name="price" value="<?=$row['pprice'];?>"/>
<input type="hidden" name="name" value="<?=$row['pname'];?>"/>
<BR><INPUT type="submit" id="submit"><div id="loading"></div>
</TD>
<?php
echo form_close();
if($first == 4) {
echo "</tr><tr>";
}
endforeach;
?>
我发送到 jquery 进行检查,但它未定义
<script type="text/javascript">
$(document).ready(function() {
$("form#addcart").submit(function() {
// Get the product ID and the quantity
var id = $(this).find('input[name=id]').val();
var qty = $(this).find('input[name=qty]').val();
alert('ID:' + id + '\n\rQTY:' + qty);
return false;
});
});
</script>
如何发送在foreach中选择的一项?