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 8479973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:10:58+00:00 2026-06-10T19:10:58+00:00

i have a dropdown list, when it changes. i want the selected value to

  • 0

i have a dropdown list, when it changes. i want the selected value to go into the controller using ajax

      $(document).ready(function () {
        $("#otherCatches").change(function () {

            $.ajax({
                url: "Clients/DDL",
                type: "POST",
                data: {
                    name: $('#othercatches').val()
                },
                success: function (result) {
                    alert(result)
                }
            });
            return false;
        });
    });

         <select id ="otherCatches">
          @foreach (var item in Model.Sample)
         {
           <option>
                @item.SampleName
           </option> 
         }
        </select>

It is not hitting the controller

[HttpPost]
public virtual ActionResult DDL(int name)
{

     //do method here

}
  • 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-10T19:10:59+00:00Added an answer on June 10, 2026 at 7:10 pm

    In your View code, you are not setting the value attribute of the option. So $('#othercatches').val() will give you undefined.

    Use the DropDownList/DropDownListFor HTML Helper method to render a SELECT element.

    Use Strongly Type Views. Ex : If your view is for Creating a DDL, You will define a viewmodel like this

    public class ClientDDL
    {
      public string Name { set;get;}  
      public int SelectedCatch { set;get;}
      public IEnumerable<SelectListItem> OtherCatches { set;get;}
      //Other relevant proeprties also here 
    
      public ClientDDL()
      {
         //Lets initialize the OtherCatches Proeprty
          OtherCatches=new List<SelectListItem>();
      }
    }
    

    Now in our GET action,We will create an object of this ViewModel and send that to the view.

    public ActionResult CreateDDL()
    {
        ClientDDL ddl new ClientDDL();
    
       // The below line is hard coded for demo. you may replace 
       //  this with loading data from your Data access layer.
        ddl.OtherCatches= new[]
        {
              new SelectListItem { Value = "1", Text = "Book" },
              new SelectListItem { Value = "2", Text = "Pen" },
              new SelectListItem { Value = "3", Text = "Computer" }
        };        
        return View(ddl);
    }
    

    Now our view (CreateDDL.cshtml),which is strongly typed to our ClientDDL class will look like this

    @model ClientDDL    
    @using(Html.Beginform())
    {
      @Html.DropDownListFor(x => x.SelectedCatch,
                       new SelectList(Model.OtherCatches,"Value","Text"), "Select..")
    
    }
    <script type="text/javascript">    
       $(function(){
          $("#SelectedCatch").change(function(){
              $.ajax({
                url: "@Url.Action("DDL","Clients")",
                type: "POST",
                data: {  name: $(this).val() },
                success: function (result) {
                    alert(result)
                 }
              });
          });
       });
    </script>
    

    Never hardcode paths to action method like that. Use the URL Helper methods wherever possible.

    Not sure why you have a virtual method ? It should be simple as this

    [HttpPost]
    public ActionResult DDL(int name)
    {
    
         //do method here
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dropdown list that when the selected value changes I want to
I have a dropdown list. I am using onchange event of this dropdown to
I have multiple dropdown list: @Html.DropDownListFor(x => x.HaveColoSpace.SelectedOptions, new SelectList(Model.HaveColoSpace.Options, Value, Text), new {
I have a drop-down list of colors, and when selected, i want to change
Everyone. I have a little issue with selecting value from the dropdown list. When
I have a drop-down list as, <select id='idleReason' onChange=loadXMLDoc(this.value) size=1> <option value=nothing selected=selected>Select a
Okay so I have two drop downs I want the selected item in dropdown
I have a cascade dropdownlist when the first change value the second change using
I have a dropdown list with a few options and a group of checkboxes
I have a dropdown list (FK) which I would like to set and display

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.