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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:52:27+00:00 2026-05-24T06:52:27+00:00

Form contains two dropdown lists created using code below. Both dropdown list elements have

  • 0

Form contains two dropdown lists created using code below.
Both dropdown list elements have property Alusdok.
If item in first dropdown is selected, second dropdown should show only those items whose Alusdok
properties have same aluses as in first dropdown selected item Alusdok property.

Both list are small, contain 1-30 elements. Which is best UI for this?
How to implement this, can some jQuery magic applied or other idea ?

<%= Html.DropDownList("_Report", Model.Reports, new { size = 10 })%>
<%= Html.DropDownList("_Paring", Model.Parings, new { size = 10 })%>


viewmodel:

    public class ReportViewModel : ViewModelBase
    {
public List<SelectListItem> Reports { get; set; }
public string _Report { get; set; }
public List<SelectListItem> Parings { get; set; }
public string _Paring { get; set; }

public ReportViewModel() {
...
            Reports = new List<SelectListItem>();
            foreach (ReportElem r in GetReportList())
                Reports.Add(new SelectListItem { Text = r.Nimetus, Value = r.Alusdok + r.Jrk.ToString() });

            Parings = new List<SelectListItem>();
            foreach (ParingElem p in GetParings())
                Parings.Add(new SelectListItem { Text= p.DisplayName, Value= p.Id.ToString() });
        }
    }


public class ReportElem {
  public string Nimetus,Alusdok;
  public int Jrk;
  }

public class ParingElem {
  public string DisplayName, Alusdok;
  public int Id;
  }

I’m using ASP.NET MVC2 , jQuery, jQueryUI

  • 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-05-24T06:52:28+00:00Added an answer on May 24, 2026 at 6:52 am

    You could create an action that accepts a ReportElem.Alusdok value and returns a JSON list of ParingElem objects.

    [HttpPost]
    public ActionResult GetParingElems(string parentAlusdok)
    {
        // construct a list formatted like this from your data layer, etc
        List<ListItem> list = new List<ListItem>() {
            new ListItem() { Value = "1", Text = "Alusdok 1" },
            new ListItem() { Value = "2", Text = "Alusdok 2" },
            new ListItem() { Value = "3", Text = "Alusdok 3" }
        };
    
        return Json(list);
    }
    

    Then, you could use jQuery to call this action and populate your second dropdown list. It looks like your dropdowns have id’s: _Report and _Paring, so I assume that below.

    $('#_Report').change(function() {
        $.ajax({
            url: 'GetParingElems',
            type: 'POST',
            data: { parentAlusdok: $('#_Report').val() },
            dataType: 'json',
            success: function(data) { // this is the returned JSON list
                $('#_Paring').remove();
                // iterate over data
                // i and optionData are arbitrary variable names
                $.each(data, function (i, optionData) {
                    $('#_Paring').append(
                        $('<option></option>').val(optionData.Value).html(optionData.Text)
                    );
                });
            }
        });
    });
    

    Keep in mind you might need to modify your routing (probably in global.asax) to accept requests of the form /ControllerName/GetParingElems/{parentAlusdok}. You may also need to tweak the url argument of the $.ajax call if your action resides in another controller, etc.

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

Sidebar

Related Questions

I'm trying to design a form which contains a dropdown box containing a list
I have a form and it contains dropdown box and different div items. Based
In my project I am making one form which contains three dropdown lists each
I have a codeigniter form that contains two checkboxes: <input type=checkbox checked=checked id=box1 name=box1
I have a page which contains two forms, both with an unique ID. I
I have two dropdowns Dropdown 1 <form:select path=StartTimings id=startTime onchange=javascript:changeTiming()> <form:option value=9:00 AM>9:00 AM</form:option>
I have a form that contains two input textboxes, one called serial and the
I have two functions to add and remove table rows that contain a form
I have a form that contains a GridView control which is databound to an
I have a form that contains a bunch of checkboxes. Before submitting the form,

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.