2013-12-09 24 views
11

私の機能だこと:私はASP.NET MVC 4を使用しています..私はラベルに合計を表示するには重み値と合計金額に追加しSelCategories.TaxSelCategories.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.jsKnockout.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; } 
    } 
+0

あなたは 'controクライアントに必要なデータを提供する '' ller''メソッドと '' actionメソッド ''メソッドがあります。また、コントローラーアクションからデータを取得するためにajax呼び出しを行うこともできます。 –

+0

問題はもう一つのドロップダウンリストは '