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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:00:30+00:00 2026-06-17T20:00:30+00:00

Hi I have some javascript which works in a standalone web page with 5

  • 0

Hi I have some javascript which works in a standalone web page with 5 divs, what it does is when an option is selected it will show a div and hide the others based on drop down selection.Basically what the code does is when a sector is selected on the drop down that corresponding DIV will be displayed eg pubs.

The problem I am having is in the web page I want this working on I have lots of Div tags and when the page loads all the Divs on the page are hidden, obviously I don’t want this.

Any help would be much appreciated

The code that hides all the divs on page load is

$('div').not(name).hide();

Is there a way of solving this problem I cant see how I am going to get round it at the moment.?

JS

<script>

    $(document).ready(function () {

        function showTab( name ) 
        {
        name = '#' + name;

        $('div').not(name).hide();

        $(name).show();
    }

    $('#dropdown').change( function() {

        showTab( $( this ).val() );
    });

    showTab( $('#dropdown').val() );

}); 

HTML

<form>
          <p>
          <select id="dropdown" name="dropdown">
              <option value="Pub-Chains" selected="selected">Pubs </option>
              <option value="Councils">Councils </option>
              <option value="Property">Property </option>
              <option value="Various">Various </option>
              <option value="Universitys">Universitys </option>
          </select>
          </p>
     </form>

My Div’s are named like so

Div id="Pub-Chains"
Div id="Councils"
Div id="Property"
Div id="Various"
Div id="Universitys"
  • 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-17T20:00:32+00:00Added an answer on June 17, 2026 at 8:00 pm

    You have to group up the div you want to participate in show hide to separate them from other divs on the page. You can assign a common class to them and use that class to hide them.

    Div id="Pub-Chains" class="opt"
    Div id="Councils" class="opt"
    Div id="Property" class="opt"
    Div id="Various" class="opt"
    Div id="Universitys" class="opt"
    
    $('div.opt').hide();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some javascript which controls a hidden div. Now it works on most
I am using some pre-written JavaScript from polldaddy. They have a JavaScript option which,
I have some old javascript code from around 2000-2002 which (surprisingly) still works in
I have some JavaScript which will do some basic error checking on my registration
I have some pretty basic Javascript here which works just fine in Firefox but
I have some javascript which catches changes to a form then calls the form's
I have some javascript which I want to convert to jQuery... I thought it
I have some Javascript attached to the Service Activity form which fires OnLoad. It
Hi I have a usercontrol which includes some JavaScript, if I add the control
I have a javascript function which needs to do a numerical calculation. Some of

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.