开发者

How do I extract the selected ID from a list box to send to a getJSON call in ASP.Net MVC app?

开发者 https://www.devze.com 2023-03-19 15:32 出处:网络
I have a list box built like so... @Html.ListBoxFor(model => model.SelectedCalendarId, Model.PeriodList)

I have a list box built like so...

@Html.ListBoxFor(model => model.SelectedCalendarId, Model.PeriodList)

and have wired up a call to my controller via jQuery and hard coded value works...

var calId = 12;
$.getJSON("/Publishing/GetLockState1", { calendarId: calId }, function (data) {//omitted}

so now, how do I get the Id the use开发者_如何学运维r has selected to pass into the json call, i.e. how to populate calId ? I tried

 calId = $("#SelectedCalendarId").val()

but no joy.


Try:

calId = $("#SelectedCalendarId :selected").val()
0

精彩评论

暂无评论...
验证码 换一张
取 消