Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8774689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:37:52+00:00 2026-06-13T18:37:52+00:00

I have the following view that has tow dropdowns and one button: @model RoomReservation.Webb.Models.HomeViewModel

  • 0

I have the following view that has tow dropdowns and one button:

@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;

}

I would like to get a value from second dropdown so that I can give it as paramater to my method f**ired from the button atribute “onclick”. It is now working (above script).
But my action still gets null parameter. Here is the code:

public ActionResult SearchForRooms(int SecondDrpId) 
    {
        if (SecondDrpId > -1)
            return View(); //Here goes some model, not important
        else
            return RedirectToRoute("Home/Index");
    }

Here is the Chrome parameter:
Request URL:http://localhost:22191/Home/SearchForRooms?parameter=3
Request Method:GET
thank you**

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:37:53+00:00Added an answer on June 13, 2026 at 6:37 pm

    You can use following code to solve your problem.

    <input id="SearchButton" type="submit" onclick="onsubmitclcik();"  disabled="disabled"/>
    

    Write a javascript function to call your next url,

    function onsubmitclcik() {
            var SecondDrpId = $('#Hotel_DDL_ID').val();
            window.location.href = '/Home/SearchForRooms?parameter=' + SecondDrpId;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an user view model that has the following properties: public User user;
I have a a view that has the following code: <h2><%= Model.Company.CompanyName %></h2> <h3>Projects</h3>
I have the following code that responds to a button click, changes the view
I have the following view: @model MyModel1 @{ ViewBag.Title = Index; Layout = ~/Views/Shared/_Layout.cshtml;
I have a view-based NSTableView that usually has one column in it. However, at
I have a view that has two buttons(First and Second) and one hidden field.
I have a User model that has a BankAccount model and I have view
Consider the following, I have a Job class that has inputs and one output.
I have a large Ruby on Rails form that has the following partial view
I have Knockout.js view model that has nested observable arrays. function ParentVM(data) { var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.