如何在选定的索引更改时将下拉选定值传递给Controller。 [英] How to Pass Dropdown selected value to Controller on Selected index change.
问题描述
大家好,
i是MVC的新手,我在项目的某个时刻陷入困境我想检查批次的可用性,我正在使用下拉列表它由Batch表填充。
我的问题是,当我从下拉列表中同时选择批次时,它会向Msg发送批次可用或不可用。
批处理表结构是:
BatchID BachName TotalSeat AvailableSeat
01 L1 50 40
02 L2 20 20 < br $>
i不知道怎么做这个任务。
Hi Everyone,
i am new to MVC and i am stuck at one point into project i wanted to check the Availability of a Batch,i am using a Dropdownlist and it is populate by Batch table.
My Question is when i am selecting a batch from drop downlist on same time it will give Msg that Batch is available or Not.
Batch Table Structure is:
BatchID BachName TotalSeat AvailableSeat
01 L1 50 40
02 L2 20 20
i don''t know how to do this task.
推荐答案
在视图中
In View
@Html.DropDownListFor(m => m.ID, Enumerable.Empty<SelectListItem>(), new {@id="batchId"})
在javaScript中
In javaScript
( function (){
(' #batchId')。change( function (){
var batchID =
('#batchId').change(function() { var batchID=
这篇关于如何在选定的索引更改时将下拉选定值传递给Controller。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!