显示基于文本框ID的相关字段

时间:2015-01-06 17:22:28

标签: asp.net-mvc-4 razor html.textboxfor editorformodel

我有两个文本框

<div>@Html.TextBoxFor(model=>model.Voyage_ID, new{id="VID"})<br /></div>


<div>@Html.EditorFor(model=>model.Arrived, new { @id = "arrived",})</div>

第一个是根据下拉列表的选定索引从json动态更新的。以同样的方式,我希望显示与在VID中捕获的id相关联的第二个字段(以及更多其他字段)。

我该如何做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以使用jQuery .change()方法:

$(document).ready(function(){
    $('#VID').change(function(){
       var currentValue = $(this).val(); //get current value of the input
       //here comes your logic
    });
})
相关问题