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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:10:43+00:00 2026-06-13T16:10:43+00:00

I want to populate one drop down list based on the selection of another

  • 0

I want to populate one drop down list based on the selection of another drop down list.

I know it’s a fairly common problem, and for two whole days I’ve been trying different samples that I find on the net, to no avail!

Here is my code:

controller:

 public List<SelectListItem> listTestCases(string id)
    {
        IQueryable<SelectListItem> A = repository.listTestCases(id);
        return (A.toList());
    }

    public JsonResult listTestCases_2(string id)
    {
        IQueryable<SelectListItem> A = repository.listTestCases(id);
        return Json(A);
    }

I have two methods, one of them returns a List, the other one JSONResults, and I tried everything I found on the net with both methods.
script:

<script>
$(document).ready(function() {
    $('select#testCategoriesUniqueId').change(function() {

        var testCategory = $(this).val();
        $.ajaxSetup({ cache: false });
        alert(testCategory);

        $.getJSON("TestInput/listTestCases/" ,  {id: testCategory}, function(data) {
            alert("here");
        });

    });
});

With the above code, the code goes through the listTestCases, and get’s the results, but It doesn’t go to the success function. (doesn’t alert)

I have tried:

 $.getJSON("TestInput/listTestCases/" + testCategory, null, function(data) {
            alert("here");
        });

not surprisingly same results.

I even tried : (json-p)

 $.ajax({
            url: "TestInput/listTestCases/" + testCategory,
            dataType: "json-p",
            success: function(data) {
                alert(data.length);
                var S = "";
                $("#testCasesUniqueId").removeOption(/./);
                for (var i = 0; i < data.length; i++) {
                    S += data[i];
                    var val = data[i].Value;
                    var text = data[i].Text;
                    $("#testCasesUniqueId").addOption(val, text, false);
                }
                alert(S);
            }
        }
        );

and the result is a string (System.collections.List[…SelectListItem]. and does not give me the objects of the list. so I tried it with listTestCases2, and it is not even calling the method.

I read somewhere that I need to use post instead of get, and I even tried postJSON. and no result.

Basically I’m super lost.

  • 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-13T16:10:44+00:00Added an answer on June 13, 2026 at 4:10 pm

    Somewhere I read that I need to use “post” method for my purpose.

     $.ajax({
                url: "TestInput/listTestCases_2/" + testCategory,
                dataType: "json",
                type: 'post',
                success: function(data) {
                    alert(data.length);
    
                }
            });
    

    Works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Drop Down Lists, the second ones are based off which one
I want to add a Select One option to a drop down list bound
I have two drop down lists. Second one is populated based on value chosen
If you populate a drop down list of possible values, you only want the
I have two drop down list on a page. The first one list projects
I want to populate a drop down list with values from database. <?php require
I want to populate a drop down menu with a column from a MySQL
Possible Duplicate: JavaScript - populate drop down list with array I have following select
I have read tutorials about how to populate an entire Drop down list with
just a quick one im looking to populate three drop down boxes to filter

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.