私の機能だこと:私はASP.NET MVC 4を使用しています..私はラベルに合計を表示するには重み値と合計金額に追加しSelCategories.Tax
とSelCategories.Duty
を取得したいモデルからJavaScript MVC 4にデータを取得するには?
<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>
これは私が私がここに最善のアプローチは、など、JSONとVue.js、Knockout.jsのようなものを使用することだと思う(だけでなく、あなたがそれを行うことができます
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; }
}
あなたは 'controクライアントに必要なデータを提供する '' ller''メソッドと '' actionメソッド ''メソッドがあります。また、コントローラーアクションからデータを取得するためにajax呼び出しを行うこともできます。 –
問題はもう一つのドロップダウンリストは '
http://stackoverflow.com/questions/10659097/jquery-get-selected-option-from-dropdown –