我有以下具有两个下拉菜单和一个按钮的视图:
@model RoomReservation.Webb.Models.HomeViewModel
@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
<fieldset>
    <legend>Select a city and a hotel</legend>
    <br />
    <br />
    <br />
    @Html.DropDownListFor(x=>x.City_DDL_ID, new SelectList(Model.AllCities, "Value", "Text"),"...pick a city..." )
    <br />
    <br />
    @Html.DropDownListFor(x => x.Hotel_DDL_ID, Enumerable.Empty<SelectListItem>(), "...pick a hotel...", new { disabled = "disabled"})
    <br />
    <br />
    <input id="SearchButton" type="submit"  onclick="window.location.href='/Home/SearchForRooms'" disabled="disabled"/> 
</fieldset>
<script type="text/javascript" language="javascript">
    $('#City_DDL_ID').change(function () {
        var selectedCity = $(this).val();
        if (selectedCity != null && selectedCity != '-1') {
            $.getJSON('@Url.Action("GetHotels")', { id: selectedCity }, function (hotels) {
                var hotelsSelect = $('#Hotel_DDL_ID');
                hotelsSelect.empty();
                $.each(hotels, function (index, hotel) {
                    hotelsSelect.append($('<option/>',
                    {
                        value: hotel.Value,
                        text: hotel.Text
                    }));
                });
                $('#Hotel_DDL_ID').attr('disabled', false);
                $('#SearchButton').attr('disabled', false);
            });
        }
    });
</script>
<script type="text/javascript" language="javascript">
 function onsubmitclcik() {
    var SecondDrpId = $('#Hotel_DDL_ID').val();
    window.location.href = '/Home/SearchForRooms?parameter=' + SecondDrpId;
}
我想从第二个下拉列表中获取一个值,以便我可以将它作为参数提供给从按钮属性“onclick”中获得的方法。它现在正在工作(在脚本上方)。但我的动作仍然得到空参数。这是代码:
public ActionResult SearchForRooms(int SecondDrpId) 
    {
        if (SecondDrpId > -1)
            return View(); //Here goes some model, not important
        else
            return RedirectToRoute("Home/Index");
    }
这是 Chrome 参数:请求 URL:http://localhost:22191/Home/SearchForRooms?parameter=3 请求方法:GET 谢谢**