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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:37:17+00:00 2026-05-15T23:37:17+00:00

I have a dropdown, and in another process add optgroups/options to that dropdown, and

  • 0

I have a dropdown, and in another process add optgroups/options to that dropdown, and that part works fine.

But I may need to add similar optgroups, with more data, and I want to check for the existence of that optgroup, and if it exists, don’t add it, but just add options to the existing optgroup.

I have been searching around, and can’t seem to find any help on selecting an optgroup.

My existing dropdown has the id of “user_search_select” and possible optgroup values could be like “dept_name” or “loc_name” or “last_name”

So after I add more data, I then may want to sort the options inside each optgroup, is that possible and how so?

Thank You!

  • 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-15T23:37:18+00:00Added an answer on May 15, 2026 at 11:37 pm

    Check this out. Although I haven’t try it it’s look like that it could do the job about the sorting.

    About the checking of existance. Basically you can check with:

    <script type="text/javascript">
        $(document).ready(function() {
            if($('#mySelect optgroup[label=New group]').html() == null){
               $('#mySelect').append('<optgroup label="New group"></optgroup>');
               $('#mySelect optgroup[label=New group]').append('<option value="1">New element</option>');
            } else {
               $('#mySelect optgroup[label=New group]').append('<option value="1">New element</option>');
            }
        });
    </script>
    

    In the script the if check if there is optgroup with label New group, if there is no such group – add the new group and then add the option in that group. The else part, just add the option in the existing New group.

    Then you should apply the sort with the plugin.

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

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The normal way to do that would be ^.$. This… May 16, 2026 at 11:28 am
  • Editorial Team
    Editorial Team added an answer -(int) returnOppositeOf:(int)myNumber aroundCenter:(int)center { return ( (center*2) - myNumber); } May 16, 2026 at 11:28 am
  • Editorial Team
    Editorial Team added an answer Create an unordered list and fill it with list items… May 16, 2026 at 11:28 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a dojo (dijit) select dropdown that calls a js function onChange. I
I have a design conundrum that I could use some feedback on, so I'm
I have a dropdown which you choose one of three values <select id=FilterType name=FilterType>
I have the standard content editor that uses an iFrame as the text area
I have an MVC page, with some controls inside a form. The part I
I have a TextBox and a DropDown inside a ListView which is binded to
I have the following code which loads a xml file to populate a dropdown.
Here's the situation I have a webpage which has one drop down called prefer.
Ok, I have a major issue with a control I am using. The site
In one of the financial Winform projects , the application code will have to

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.