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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:37:31+00:00 2026-05-20T21:37:31+00:00

I have a select with 2 optgroups. Is there a way to call an

  • 0

I have a select with 2 optgroups. Is there a way to call an function only if an option from the first optgroup is selected and call another function if an option from the second optgroup is selected?

  • 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-20T21:37:31+00:00Added an answer on May 20, 2026 at 9:37 pm

    Sure.

    HTML:

    What is your preferred vacation spot?<br>
    <SELECT ID="my_select"> 
    
    <OPTGROUP LABEL="OptGroup One." id="one">        
    <OPTION LABEL="Florida">Florida</OPTION>         
    <OPTION LABEL="Hawaii">Hawaii</OPTION>         
    <OPTION LABEL="Jersey">Jersey Shore</OPTION>    
    </OPTGROUP> 
    
    <OPTGROUP LABEL="OptGroup Two" id="two">  
    <OPTION LABEL="Paris">Paris</OPTION>  
    <OPTION LABEL="London">London</OPTION> 
    <OPTION LABEL="Florence">Florence</OPTION>  
    </OPTGROUP>
    
    </SELECT>
    

    JS:

    $("#my_select").change(function(){
        var selected = $("option:selected", this);
        if(selected.parent()[0].id == "one"){
            //OptGroup 1, do something here..
        } else if(selected.parent()[0].id == "two"){
            //OptGroup 2, do something here
        }
    });
    

    Example here: http://jsfiddle.net/pyG2v/

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

Sidebar

Related Questions

Now i have a select box. <select multiple size=5 name=interest> <optgroup label=Sports> <option value=>Footaball</option>
I have the following select: <select name=end id=end> <optgroup label=Morning> <option value=12:00a>12:00 am</option> <option
Right now, I have SELECT gp_id FROM gp.keywords WHERE keyword_id = 15 AND (SELECT
I want to have a select-only ComboBox that provides a list of items for
Suppose I have a SELECT statement that returns some set of results. Is there
I am trying to find a way to have a SELECT statement return the
I have this script: select name,create_date,modify_date from sys.procedures order by modify_date desc I can
I have need to select a number of 'master' rows from a table, also
I have a select list with optgroups. I want to add a handler for
I have a dropdown, and in another process add optgroups/options to that dropdown, and

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.