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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:58:00+00:00 2026-06-15T13:58:00+00:00

My dropdown values are showing alphabetical order. But i dont need like that. Because

  • 0

My dropdown values are showing alphabetical order. But i dont need like that. Because when I add values it is changing the alphabetical order.

For Example,

I have number of functions

  1. — Designer– // Subfunction

  2. Accessory Designer

..so on.

But My dropdown showing

  1. Accessory Desinger,

  2. –Desinger–.

My Jquery code here

 $('#dropdown').change(function () {
    $("#dropdown1").show();
    $.ajax({
        url: "/Jobs/dropdown1",
        type: 'GET',
        data: { 'dropdownId': $(this).val() },
        dataType: 'json',
        success: function (response) {
            if (response.Success) {
                $('#dropdown1').children().remove();

                $.each(response.dropdown1, dropdown (index, role) {
                    $('#dropdown1').append(
                        '<option value="' + dropdown1.Id + '">' +
                            dropdown1.Name +
                        '</option>');
                });
            }
        },
        error: function (xhr, status, error) {

        }
    });
});

when I click first dropdown, It is automatically show the second Dropdown.

Please help me out of this problem.

  • 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-15T13:58:01+00:00Added an answer on June 15, 2026 at 1:58 pm

    If you don’t know how to change the order on the server side, you must do it in the client.

    From your description I gather the result is a JSON object with each item having Id and Name, and that you want to iterate them not by name, but by id.

    Therefore I suggest the following change to your code:

    if (response.Success) {
        $('#Roles').children().remove();
    
        var results = [];
        // Converting the JSON object into an array
        $.each(response.Roles, function(index, role) {
            results.push(role);
        });
    
        // Sorting the array items by Id
        results.sort(function(a, b) {
            return a.Id - b.Id;
        });
    
        $.each(results, function (index, role) {
            $('#Roles').append(
                '<option value="' + role.Id + '">' +
                    role.Name +
                '</option>');
        });
    }
    

    That should sort the resultset by Id before the items are added to #Roles.

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

Sidebar

Related Questions

I want Add Select Activity values as first values of HTML dropdown, but when
On a aspx page, I have to load a DropDown with some values coming
Suppose I have a dropdown (select tag) with 3 values. Our first option has
I have a dropdown selector, with values from 1-4. Depending on the selection, subsequent
I have a dropdown control, with some values I added in using the designer.
I have been searching for an example/demo on spinner showing display text tie with
I have a select tag. ON keydown of that dropdown i'm setting some selecting
I have a table showing records from database. There is a dropdown for selecting
I have a dropdown menu on my site that I want to use to
I need to retrieve all of the selected values of each dropdown list on

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.