من یک input از تایپ number دارم که داخل یک پیش فاکتور قرار داره ،میخوام وقتی مشتری تعداد محصول رو تایپ کرد ،جمع قیمت محصولات متناسب با تعداد محصولات تغییر کنه،این کد من هست.
کد HTML:
<td>
<input type="number" id="inputnumber" value="@item.ProductCount" min="0" style="width: 70px;"
onchange="ChangeCount(@item.ProductId)">
</td>
و این کنترلر من هست.
public ActionResult InputNumber(int id)
{
List<ShowShoppingCart> shopcart = new List<ShowShoppingCart>();
List<ShopCartItem> shop = Session["ShoppingCart"] as List<ShopCartItem>;
int index = shop.FindIndex(s => s.ProductId == id);
shop[index].ProductCount = shopcart.Count;
if (shop[index].ProductCount == 0)
{
shop.Remove(shop[index]);
}
Session["ShoppingCart"] = shop;
return RedirectToAction("Index");
}
و اینها هم کلاسها هستن:
public class ShowShoppingCart
{
[Key]
public int ProductId { get; set; }
[Display(Name ="نام محصول")]
public string ProductTitle { get; set; }
[Display(Name = "تعداد")]
public int ProductCount { get; set; }
[Display(Name = "مبلغ")]
public int? ProductPrice { get; set; }
[Display(Name = "جمع ")]
public int? Sum { get; set; }
[Display(Name = "جمع با تخفیف ")]
public int? SumWithDiscount { get; set; }
[Display(Name = "جمع کل ")]
public int? TotalSum { get; set; }
[Display(Name = "جمع کل با تخفیف ")]
public int? TotalsumWithDiscount { get; set; }
public int DiscountPercent { get; set; }
}
public class ShopCartItem
{
public int ProductId { get; set; }
public int ProductCount { get; set; }
}
@section Script
{
<script type="text/javascript">
function ChangeCount(id) {
$(document).ready(function () {
$.ajax({
url: "/ShoppingCart/InputNumber",
type: "Get",
data: { id: id }
}).done(function (result) {
$('#CountShopCart').html(result);
//$('#inputnumber').html(result);
});
});
}
</script>
}
وقتی عددی رو تایپ میکنم هیچ اتفاقی نمیفته ؟ چرا؟