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

  • Home
  • SEARCH
  • 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 69699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:36:54+00:00 2026-05-10T19:36:54+00:00

is there a quick way to sort the items of a select element? Or

  • 0

is there a quick way to sort the items of a select element? Or I have to resort to writing javascript?

Please any ideas.

<select size='4' name='lstALL' multiple='multiple' id='lstALL' tabindex='12' style='font-size:XX-Small;height:95%;width:100%;'> <option value='0'> XXX</option> <option value='1203'>ABC</option> <option value='1013'>MMM</option> </select> 
  • 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. 2026-05-10T19:36:54+00:00Added an answer on May 10, 2026 at 7:36 pm

    This will do the trick. Just pass it your select element a la: document.getElementById('lstALL') when you need your list sorted.

    function sortSelect(selElem) {     var tmpAry = new Array();     for (var i=0;i<selElem.options.length;i++) {         tmpAry[i] = new Array();         tmpAry[i][0] = selElem.options[i].text;         tmpAry[i][1] = selElem.options[i].value;     }     tmpAry.sort();     while (selElem.options.length > 0) {         selElem.options[0] = null;     }     for (var i=0;i<tmpAry.length;i++) {         var op = new Option(tmpAry[i][0], tmpAry[i][1]);         selElem.options[i] = op;     }     return; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To find duplicates you can use sort | uniq -d but is there a
Let's say I have a data.frame x <- data.frame(a = c('A','A','A','A','A', 'C','C','C','C', 'B','B','B'), b
I have a 2D numpy array. Some of the values in this array are
I have a vector<data> info where data is defined as: struct data{ string word;
I have an autocomplete on my site where a user enters a class at
I wrote a quick console application that uses SharePoint dll files. If I attempt
I am trying to monitor drives a local PC. I am interested in two
Sorry, but apparently I don't understand chaining enough to figure out this problem... I'm
If I want to remove lines where certain fields are duplicated then I use
I'm trying to figure out which files in Python's (Python 2.6/Python 2.7) tcl folder

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.