这是我的函数:
<script> function Calculate()
{
var ItemPrice = document.getElementById("price");
var weight = document.getElementById("weight");
var SelWeight = weight.options[weight.selectedIndex].value;
alert(SelWeight);
var Category = document.getElementById("SelectedCategory");
var SelCategory = Category.options[Category.selectedIndex].value;
alert(SelCategory);
}
</script>
我想获取SelCategories.Tax
和SelCategories.Duty
,将它们添加到重量值和总价中,并在标签中显示总数。我正在使用ASP.NET MVC 4,这是我想要使用的模型。public class CategoriesModel
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
public decimal Duty { get; set; }
public decimal Tax { get; set; }
public IEnumerable<SelectListItem> CategoriesList { get; set; }
}
控制器
和一个操作方法
,以便为客户端提供所需的数据。然后你可以发起一个ajax调用来从控制器操作中检索数据。 - Shuhel Ahmed<select>
标签,我该如何将所选值传递给控制器? - YaraHanaa<select>
,另一个使用这个模型@MattBodily。 - YaraHanaa