1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<div class="row">
@{ var album = Model.Produits.ToArray();}
@for (int i = 0; i < album.Length; i++) {
<div class="col-lg-3 col-xs-6">
<div class="box box-info center ">
<div class="form-horizontal">
<div class="box-body">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.Hidden("id", album[i].ProduitId, new { @id = "id" })
<img src=" ~/imagess/@album[i].ImagePath" Width="200" Height="200" class="center" /><br />
<br />
<b>@album[i].Nom_Produit </b>
<div class="pull-right hidden-xs">
<i> @String.Format("{0:F}", album[i].Prix) Dh</i>
</div>
<br />
<br />
<div class="pull-left hidden-xs ">
<p>Quantité : </p>
</div>
@Html.TextBox("quant"+album[i].ProduitId, null, new { @class = "col-md-3 col-md-offset-1"}) @Html.ValidationMessage("quant")
<button class="bg-primary col-md-4 col-md-offset-5">
@Html.ActionLink("Ajouter", "AddToCart", "ShoppingCart", new{ data_id = id, id = album[i].ProduitId}, new{ @class = "Sendparams"})
</button>
</div>
</div>
</div></div>
}
</div>
<script type="text/javascript">
$(function(){
$('.Sendparams').click(function (e){
e.preventDefault();
debugger;
var id = $(this).data("id");
var quant = $("#quant"+id).val();
$.ajax({
type: 'GET',
url: '/ShoppingCart/AddToCart',
data:{"id": id , "quant": quant },
success: function (response){
$("#mainContainerCenter").html(response); }});});
});
</script> |
Partager