0
我有一個環形的形式工作,每個人都有一個提交按鈕和我添加的JavaScript,當我點擊,它不會重定向到其他頁面jQuery的不以循環形式
但是,當我試圖提交的JavaScript ISN 「T工作它重定向到其他網頁,我希望有人能幫助我
這些都是從我的loadProduct功能我的代碼
<?php
include('../classes/class.product.php');
$cat = $_POST['categ'];
$p= new Product();
?>
<table class="w3-table table table-bordered w3-striped w3-card-4">
<thead>
<tr class="w3-green">
<th>Product Name</th>
<th>Price</th>
<th>Remaining Stock </th>
<th>Add to List</th>
</tr>
</thead>
<?php
$list_of_product=$p->loadAllProductAccToCategory($cat);
foreach ($list_of_product as $product) {
?>
<tr>
<td><?php echo $product->prodname; ?></td>
<td><?php echo $product->price; ?></td>
<td><?php echo $product->remaining_stock; ?>Piece(s)</td>
<td>
<form class ="<?php echo $product->prodname; ?>" action="functions/InsertOrders.php" method = "POST">
<input class='form-control' name='qty' type='text' placeholder="Enter Quantity" autocomplete="off" required />
<input type="hidden" name='en' value=<?php echo $product->id; ?> />
<input type="hidden" name='price' value=<?php echo $product->price; ?> />
<input type="hidden" name='rstock' value=<?php echo $product->remaining_stock; ?> />
<button <?php if ($product->remaining_stock<1) { ?>
disabled="true" class='btn btn-danger glyphicon glyphicon-pencil'
<?php } ?> class='btn btn-primary glyphicon glyphicon-pencil <?php echo $product->id; ?>'>Add</button>
</td>
</form>
</tr>
<script type="text/javascript">
$(".<?php echo $product->id; ?>").click(function(){
$.post($(".<?php echo $product->prodname; ?>").attr("action"),$(".<?php echo $product->prodname; ?> :input").serializeArray(),function(sv){alert(sv);})
clear();
});
$(".<?php echo $product->prodname; ?>").submit(function(){
return false;
});
function clear(){
$(".<?php echo $product->prodname; ?> :input").each(function(){
$(this).val('');
});
}
</script>
<?php
}
?>
</table>
<!-- <script type="text/javascript">
$(".sub").click(function(){
$.post($(".myForm").attr("action"),$(".myForm :input").serializeArray(),function(sv){alert(sv);})
});
$(".myForm").submit(function(){
return false;
});
function clear(){
$(".myForm :input").each(function(){
$(this).val('');
});
}
</script> -->
您已打開和
。看看你的第4個。 – RPichiolithere are .. below below sir ..在結束之前表格 –
你已經倒過來了,試試
– RPichioli