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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:56:33+00:00 2026-05-26T08:56:33+00:00

I have the following 2 select lists.. I’d like to hide State/Prov until the

  • 0

I have the following 2 select lists.. I’d like to hide State/Prov until the chosen Country has a corresponding optgroup label. So..

–User Selects Alegeria.. No State select is shown..

–User Selects United States or Canada; The State Selects appears showing only the values where optgroup label matches the parents name.

Make Sense? Can’t find a way to do it based on OptGroup vs. having to manually assign a ‘class’ to each child object

<select id="C_Country" name="C_Country" aria-required="true" class="required">
    <option value=" " selected="">-- Please Select --</option>
    <option value="AF">Afghanistan</option>
    <option value="AX">Aland Islands</option>
    <option value="USA">United States</option>
    <option value="DZ">Algeria</option>
    <option value="CA">Canada</option>
    <option value="AD">Andorra</option>
</select>


<p><label for="C_State_Prov">State or Province <span title="required">*</span></label></p>
<select id="C_State_Prov" name="C_State_Prov" aria-required="true" class="required">
    <option value="" selected="">-- Please Select --</option>
    <optgroup label="United States">
    <option value="AK">Alaska</option>
    <option value="AL">Alabama</option>
    <option value="AR">Arkansas</option>
    <option value="AZ">Arizona</option>
    <option value="CA">California</option>
    </optgroup>
    <optgroup label="Canada">
    <option value="AB">Alberta</option>
    <option value="BC">British Columbia</option>
    <option value="MB">Manitoba</option>
    </optgroup>
</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. Editorial Team
    Editorial Team
    2026-05-26T08:56:33+00:00Added an answer on May 26, 2026 at 8:56 am

    I think this is what you want.

    $(function(){
       var state_province = $('#C_State_Prov option, #C_State_Prov optgroup'); 
       state_province.hide();  // hide all state and provinces on page load
    
    
       $('#C_Country').change(function(){
           state_province.hide(); // on change of drop down hide all state provinces
    
           // find the optgroup with the label = the html of the selected dropdown 
           // select the opt group and all of it's children and show them 
           $("#C_State_Prov optgroup[label='"+$(this).find(':selected').html() + "']")
           .children()
           .andSelf()
           .show();  
       }); 
    }); 
    

    This can be cleaned up a little more but you get the idea.

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

Sidebar

Related Questions

I have the following select list from which the user can select multiple values.
I have the following drop down list: <select name=selSS1 id=select_value> <option value=val0>sea zero</option> <option
I have following select results: Select t1.ID, t1.Value1 from t1 where t1.ID=1 Result: ID
I have the following select field and based on whether the class .show-x-trend or
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following multi-select box in a HTML form, where user can select
I have the following query SELECT e.topicShortName, d.catalogFileID, e.topicID FROM catalog_topics a LEFT JOIN
I have the following script select c.id from .TBL_COUPONS. as c inner join .TBL_BUSINESS.
I have the following query SELECT s.name, s.surname, s.id_nr, s.student_nr, s.createdate, s.enddate, (SELECT count(*)
I have the following lists of topics added using the template as follows //Template

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.