1
我有一個觀點:我應該使用哪種視圖?
<table id="cartbox">
<thead>
<tr>
<th>Tên hàng</th>
<th>Số lượng</th>
<th>Đơn giá</th>
<th colspan="2" style="width:70px">Thành tiền</th>
</tr>
</thead>
<tbody>
@foreach (var line in Model.Cart.Lines)
{
<tr>
<td>@line.Product.Name
</td>
<td class="qty">@Html.DropDownList("Quantity", new SelectList(ViewBag.Items as System.Collections.IList, "Value", "Text", line.Quantity))</td>
<td style="color:#3A9504;margin-left:3px" class="price">@string.Format("{0:00,0 VNĐ}", line.Product.Price)</td>
<td class="subtotal">@string.Format("{0:00,0 VNĐ}", (line.Quantity * line.Product.Price))</td>
<td align="center" style="width:10px"><a href="@Url.Action("RemoveFromCart","Cart",new{ProID= line.Product.ProductID, returnUrl= Request.Url.PathAndQuery})"><img src="@Url.Content("~/Content/Images/delete.png")" style="padding-right:10px" /></a></td>
</tr>
}
</tbody>
<tfoot>
<tr style="border-top-style:solid;border-top-color:#DFDFDF;border-top-width:1px;">
<td colspan="3" align="right" style="border-right-color:#808080;border-right-style:solid;border-right-width:1px;text-align:right"><b>Tổng tiền:</b></td>
<td style="text-align: center"><b>@string.Format("{0:00,0 VNĐ}", Model.Cart.ComputeTotalValue())</b></td>
<td></td>
</tr>
</tfoot>
</table>
哪些jQuery的AJAX功能,我應該使用更新分類彙總&總當DROPDOWNLIST用戶更改數量:
function CalValue() {
$("#select").change(function() {
var quantity = $(this).val();
var fprice = $(this).closest("tr").find("td[class^=price]").html();
var price = fprice.replace(/[,\s(VNĐ)]/g, '')
var fsubtotal = parseInt(quantity) * parseInt(price);
var subtotal =
$(this).closest("tr").find("td[class^=subtotal]").html(subtotal);
});
}
使用此功能的問題在我刷新頁面之後,頁面返回到orgrinal值,沒有任何變化。 或
function UpdateValue() {
$(document.body).on("change", ".Quantity", function() {
var ProID = $(this).attr("data");
var Quatity = $(this).val();
$.ajax({
type: "GET", url: "/Cart/UpdateValue",
data: { ProID: ProID, quantity: Quatity },
success: function (data) {
$("#cartbox").html(data);
}
}
);
$.ajaxSetup({
cache: false
});
});
}
而這個問題是,它返回一個新的視圖,但下拉列表中查看複製。
任何人都可以告訴我如何控制或使用哪種方法?請。