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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:40:47+00:00 2026-06-11T08:40:47+00:00

Im looking for a select box that i can use that has expandible optgroups

  • 0

Im looking for a select box that i can use that has expandible optgroups

The options in the groups should not display until the mouse is move over the optgroup label

<select>
 <optgroup label="group 1"> 
  <option>1</option> <!-- Options within this group hidden until mouseover its group label -->
  <option>2</option>
  <option>3</option>
  <option>4</option> 
 </optgroup>
 <optgroup label="group 2">
  <option>1</option> <!-- Options within this group hidden until mouseover its group label -->
  <option>2</option>
  <option>3</option>
  <option>4</option>
 </optgroup>
 <optgroup label="group 3">
  <option>1</option> <!-- Options within this group hidden until mouseover its group label -->
  <option>2</option>
  <option>3</option>
  <option>4</option>
 </optgroup>
</select>

I want to be able to do this becuase am going to have some very large options and it will help break them down.

If i am unable to do this through an HTML select box + JS i would like to build a customised dropdown that will support this using DIV tags. If anyone knows where i can find any information about this or a tutorial that would be great.

Thanks

  • 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-11T08:40:48+00:00Added an answer on June 11, 2026 at 8:40 am

    NVM i found a solution that works,

    I had to use HTML, CSS and JS to achieve what i wanted.

    I copied this tutorial
    http://www.onextrapixel.com/2012/06/20/create-a-custom-select-box-with-jquery/

    and added the extra bits i needed to generate the groups and functionality.

    The code that works for me is below….

    This is the HTML to generate the layout

      <div class='selectBox'>
        <span class='selected'>Reset Filter</span> <span class=
        'selectArrow'>&amp;#9660</span>
        <div class="selectOptions">
          <div>
            <span class="selectOption c1" value="reset" group="0">Reset Filter</span>
          </div>
          <div>
            <span class="selectOption c1" value="online_booking" group="1">Online
            Booking</span>
          </div>
          <div>
            <span class="selectOptionGroup" value="2">&gt;&gt; Services Offered</span>
            <span class="selectOption" value="SERVICING" group="2">SERVICING</span>
            <span class="selectOption" value="MOT TESTING" group="2">MOT TESTING</span>
            <span class="selectOption" value="TYRES" group="2">TYRES</span>
          </div>
          <div>
            <span class="selectOptionGroup" value="3">&gt;&gt; Car Manufacturer</span>
            <span class="selectOption" value="ALFA ROMEO" group="3">ALFA ROMEO</span>
            <span class="selectOption" value="ASTON MARTIN" group="3">ASTON MARTIN</span>
            <span class="selectOption" value="AUDI" group="3">AUDI</span>
          </div>
        </div>
      </div>
    

    This is the Jquery JS code that creates the dropdown

        function enableSelectBoxes(){
                $('div.selectBox').each(function(){
                    $(this).children('span.selected').html($(this).children('div.selectOptions').children('span.selectOption:first').html());
                    $(this).attr('value',$(this).children('div.selectOptions').children('span.selectOption:first').attr('value'));
    
                    $(this).children('span.selected,span.selectArrow').click(function(){
                            if($(this).parent().children('div.selectOptions').css('display') == 'none'){
                                    $(this).parent().children('div.selectOptions').css('display','block');
                            }
                            else
                            {
                                    $(this).parent().children('div.selectOptions').css('display','none');
                            }
                    });
    
                    $(this).find('span.selectOption').click(function(){
                            $(this).parent().parent().css('display','none');
                            $(this).closest('div.selectBox').attr('value',$(this).attr('value'));
                            $(this).parent().parent().siblings('span.selected').html($(this).html());
                            $("#filter_type").val($(this).attr("group"));
                            $("#filter_value").val($(this).attr("value"));
                    });
    
                    $(this).find('span.selectOptionGroup').click(function(){
                        var group = $(this).attr("value");
                        $(this).parent().children("span[group='" + group + "']").each(function(){
                            if($(this).css("display") == "block") {
                                $(this).css("display", "none");
                            }
                            else {
                                $(this).css("display", "block");
                            }
                        });
                    });
                });
        }
    

    And finally the CSS

    div.selectBox {
        position: relative;
        display: inline-block;
        cursor: default;
        text-align: left;
        line-height: 30px;
        clear: both;
        color: #888;
        margin-top: 20px;
    }
    
    span.selected {
        width: 167px;
        text-indent: 20px;
        border: 1px solid #ccc;
        border-right: none;
        border-top-left-radius: 5px;
        border-bottom-left-radius: 5px;
        background: #f6f6f6;
        overflow: hidden;
    }
    
    span.selectArrow {
        width: 30px;
        border: 1px solid #9FD573;
        border-top-right-radius: 5px;
        border-bottom-right-radius: 5px;
        text-align: center;
        font-size: 20px;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -o-user-select: none;
        user-select: none;
        background: #9FD573;
    }
    
    span.selectArrow,span.selected {
        position: relative;
        float: left;
        height: 30px;
        z-index: 1;
    }
    
    div.selectOptions {
        position: absolute;
        top: 28px;
        left: 0;
        width: 198px;
        border: 1px solid #ccc;
        border-bottom-right-radius: 5px;
        border-bottom-left-radius: 5px;
        overflow: hidden;
        background: #f6f6f6;
        padding-top: 2px;
        display: none;
        max-height: 400px;
        overflow: auto;
    }
    
    span.selectOption, span.selectOptionGroup {
        width: 80%;
        line-height: 20px;
        padding: 5px 10%;
    }
    
    
    span.selectOption{
        display: none;
    }
    
    span.selectOption:hover, span.selectOptionGroup:hover {
        color: #f6f6f6;
        background: #4096ee;
    }
    
    span.selectOptionGroup {
        display: block;
        font-weight: bold;
        font-style: italic;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a searchable multiple select javascript widget that can handle filtering
Looking for a control that allows to select one text value at a time
I looking for a script that will enable me to select an area in
I'm trying to make a box that allows you to select some variables, and
I'm using ExtJS 2.3.0 and am looking for a combo box that allows mulitple
I am looking for an example that has some good patterns for doing a
I'm looking for a jQuery plugin that either replaces or improves the HTML <select>
So I just want to make a simple combo box that has 2 values,
I am looking for a multiple file uploader that can upload limited number of
I am looking for a multi-select jquery based two-column transfer widget having a look

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.