我有一個文本框,在我看來,這樣的我想將文本框的值發送到控制器的MVC
< input type="text" id="Quant" value="@item.Quantity"/>
我想這個文本框的值發送到操作方法時,文本框的值被改變。
我的操作方法是這樣的
public ActionResult Quant(int id)
{
int index = isExisting(id);
List<Item> cart = (List<Item>)Session["cart"];
cart[index].Quantity= id;
Session["cart"] = cart;
return View("Cart");
}
我想要的文本框的值將被髮送到的ActionResult定量的參數ID。 我們是否可以使用任何JavaScript或jQuery爲此。 plz幫助我。提前致謝。
爲什麼使用javascript?爲什麼不提交一個表單(你需要給輸入一個名稱屬性'name =「id」') –
javascript不需要頁面更新。它非常簡單,並使您的網站互動。 –