这是我的代码。
<div class="editor-label">
@Html.LabelFor(model => model.Branch)
</div>
<div class="editor-field">
@{ Booking_Program.Models.Booking_DB_Entities db = new Booking_Program.Models.Booking_DB_Entities();
<select onchange="onChangeBranch()" id="branchStr">
@for (int i = 0; i <= 3;i++ )
{
<option id="@i" value="@i.ToString()">@i.ToString()</option>
}
</select>
}
@Html.TextBoxFor(model => model.Branch, new { id = "branch" })
@Html.ValidationMessageFor(model => model.Branch)
</div>
javascript如下。
<script type="text/javascript">
function onChangeBranch() {
var brnch = document.getElementById("branchStr").value;
alert(brnch);
$("#branch").val(brnch).change();
}
</script>
这段代码有什么问题?我明白alert
了,但这不会改变TextboxFor
. 怎么做?