0
我正在使用ASP MVC 3,并且当我更改我的dropdownlistfor的值时,当前有问题在我的文本框中获取新数据。更改TextBoxFor当更改DropDownListFor
<div id="BagelProductEdit">
<h2>Bagel</h2>
@Html.DropDownListFor(x => x.SelectedOptionBagel, Model.LstBagelsList, new { @class = "width200", @onchange = "refreshTextBoxFors()" })
<br />
<table>
<tr>
<td>Bagelnaam</td><td> @Html.TextBoxFor(x => x.LstBagels.ElementAt(x.SelectedOptionBagel).Name,new { Name ="txtEditBagelName" })</td>
</tr>
<tr>
<td>Vertaling</td><td> @Html.TextBoxFor(x => x.LstBagels.ElementAt(x.SelectedOptionBagel).NameFr,new { Name ="txtEditBagelNameFr" })</td>
</tr>
<tr>
<td>Prijs</td>
<td> @Html.TextBoxFor(x => x.LstBagels.ElementAt(x.SelectedOptionBagel).Price,new { Name ="txtEditBagelPrice" })</td>
</tr>
</table>
<input class="button widthorderProduct" type="submit" name="BtnEditBagel" value="Edit een bagel" />
</div>
当我的下拉列表的值发生变化时,如何在我的文本框中获取刷新值?
这是一个很好的例子,如何检索索引,但仍textboxfors没有更新.. 我现在有一个功能,从下拉列表retreive指数: 功能refreshTextBoxFors(){ $(“#bagelname” ).VAL($( “#myDDL”)VAL())。 index = $(“#bagelname”)。val(); } 这是我textboxfor: Bagelnaam@ Html.TextBoxFor(X => x.LstBagels.ElementAt(指数).name和新{名称= “txtEditBagelName” ID = “测试”}) –