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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:29:08+00:00 2026-05-25T20:29:08+00:00

I am working on with three drop-down menus each of which have three options.

  • 0

I am working on with three drop-down menus each of which have three options. Together these three drop-down menus create a system that can be in any one of twenty seven states. For each drop-down, there is option 1, option 2, and all (which is the union of option 1 and 2).

Depending on what state these three drop-down menus are in, I want to display or hide different divs. These divs have classes of this form class="distribution-(select-1)-(select-2)-(select-3)"

I am trying to find a DRY way of coding this up without relying on 27 different conditionals.

Here are the drop-down menus:

<div  style = "margin-top:1cm; font-size:125%">
    <strong>Clickout Type&nbsp;</strong>
    <select class = "clickouts" >
        <option value = "all" selected="selected">All</option>
        <option value = "clickouts" >Clickouts</option>
        <option value = "preferred" >Preferred Clickouts</option>
    </select>
    <strong>Graph Type&nbsp;</strong>
    <select class = "graph-type" >
        <option value = "all" selected="selected">All</option>
        <option value = "hist" >Histograms</option>
        <option value = "percent" >Percent</option>
    </select>
    <strong>Roll-up Type&nbsp;</strong>
    <select class = "roll-up" >
        <option value = "all" selected="selected">All</option>
        <option value = "aggregate" >Aggregate</option>
        <option value = "granular" >Granular</option>
    </select>
</div>

Here are some examples of the div classes:
distribution-hist-clickouts-aggregate, distribution-percent-clickouts-aggregate, class="distribution-hist-clickouts-granular", distribution-percent-clickouts-granular

Here is the jquery for the first seven states:

$('.clickouts, .graph-type, .roll-up').change(function(){
    var graph_type = $('.graph-type').val(); 
    var roll_up = $('.roll-up').val();
    var clickouts = $('.clickouts').val(); 

    if (graph_type == 'all' & roll_up == 'all' & clickouts == 'all'){
        $('div[class*="distribution"]').css('display', 'block');
    }
    if (graph_type == 'all' & roll_up == 'all' & clickouts == 'clickouts'){
        $('div[class*="clickout"]').css('display', 'block');
        $('div[class*="preferred"]').css('display', 'none');
    }

    else if (graph_type == 'all' & roll_up == 'all' & clickouts == 'preferred'){
        $('div[class*="clickout"]').css('display', 'none');
        $('div[class*="preferred"]').css('display', 'block');
    }

    else if (graph_type == 'hist' & roll_up == 'all' & clickouts == 'all'){
        $('div[class*="hist"]').css('display', 'block');
        $('div[class*="percent"]').css('display', 'none');
    }

    else if (graph_type == 'percent' & roll_up == 'all' & clickouts == 'all'){
        $('div[class*="hist"]').css('display', 'none');
        $('div[class*="percent"]').css('display', 'block');
    }

    else if (graph_type == 'all' & roll_up == 'aggregate' & clickouts == 'all'){
        $('div[class*="aggregate"]').css('display', 'block');
        $('div[class*="granular"]').css('display', 'none');
    }

    else if (graph_type == 'all' & roll_up == 'granular' & clickouts == 'all'){
        $('div[class*="aggregate"]').css('display', 'none');
        $('div[class*="granular"]').css('display', 'block');
    }
});
  • 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-25T20:29:09+00:00Added an answer on May 25, 2026 at 8:29 pm

    If you will change your complex class class="distribution-(select-1)-(select-2)-(select-3) to set of classes class="distribution (select-1) (select-2) (select-3) you can use the following script:

    $('.clickouts, .graph-type, .roll-up').change(function(){
        var graph_type = $('.graph-type').val(); 
        var roll_up = $('.roll-up').val();
        var clickouts = $('.clickouts').val(); 
    
        graph_type = (graph_type == "all" ? "" : "." + graph_type);
        roll_up = (roll_up == "all" ? "" : "." + roll_up);
        clickouts = (clickouts == "all" ? "" : "." + clickouts);
    
        var selector = '#container div' + graph_type + roll_up + clickouts;
    
        $('#container div:visible').hide();
        $(selector).show();
    });
    

    Code: http://jsfiddle.net/9R5zj/9/

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

Sidebar

Related Questions

I have been working on a drop down menu, that has different colors for
I have a page I'm working on that encompasses a vertical drop-down menu. However,
I want to create a drop-down menu in which we can see all the
I'm working on a page that has three divs next to each other, each
I have this drop down menu that when one menu is clicked if there
I have this form section with dynamic clone of select drop down menus. The
I'm working on writing a drop-down menu with jQuery and I have a question.
I am working on making some drop-down menus. Our designer prescribed a gap between
I'm trying to create a drop down menu that points to a directory and
I have an expandable vertical drop down menu that currently expands when first level

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.