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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:27:17+00:00 2026-05-13T11:27:17+00:00

– – edited as i described it incorrectly first time round, sorry! – –

  • 0

– – edited as i described it incorrectly first time round, sorry! – –

Hi,

i am trying to use show/hide to manipulate what is shown in a second dropdown menu, based on what is selected in the first dropdown menu. However after having it work briefly, it now doesn’t across any browser, it just shows them all no matter what is selected. When an option is selected in the first menu, it needs to then display particular options in the second menu. Each airport has it’s own set of destinations. Unfortunately there isn’t a php/mysql database option for this :/

the js is as follows:

$(document).ready(function(){

$("#from_BLANK").click(function () {
        $("#to_A1").show();
        $("#to_A2").show();
        $("#to_A3").show();
    });
    $("#from_A1").click(function () {
        $("#to_A1").hide();
        $("#to_A2").show();
        $("#to_A3").show();
    });
    $("#from_A2").click(function () {
        $("#to_A1").show();
        $("#to_A2").hide();
        $("#to_A3").show();
    });
    $("#from_A3").click(function () {
        $("#to_A1").show();
        $("#to_A2").show();
        $("#to_A3").hide();
    });
});

And the html on the dropdowns is as follows:

<select name="depApt" id="depApt">
    <option id="from_BLANK" selected="selected">&nbsp;</option>
    <option id="from_A1" value="A1">Airport One</option>
    <option id="from_A2" value="A2">Airport Two</option>
    <option id="from_A3" value="A3">Airport Three</option>
</select>

<select name="dstApt" id="dstApt">
    <option id="to_BLANK" selected="selected">&nbsp;</option>
    <option id="to_A1" value="A1">Airport One</option>
    <option id="to_A2" value="A2">Airport Two</option>
    <option id="to_A3" value="A3">Airport Three</option>
</select>

Are there any glaring errors? or maybe better ways to achieve this?

Any and all help most appreciated!

cheers,
Paul

  • 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-13T11:27:17+00:00Added an answer on May 13, 2026 at 11:27 am

    Here’s the script which will prevent both dropdown from being the same other than both are blank. The option in B will always be disabled if the corresponding one in A is selected.

    Tested in IE8 and FF3.5 and Chrome.

    Javascript:

     <script type="text/javascript" >
        $(function() {
        $('#depApt').click(function(){
            var idx = $(this).attr("selectedIndex") + 1;
            $('#dstApt option').removeAttr('disabled');
            if($('#dstApt').attr("selectedIndex") == idx - 1)
              $('#dstApt').attr("selectedIndex", 0)
            $('#dstApt option:nth-child(' + idx + ')').attr('disabled', 'disabled');
          }
        );
        });
      </script>
    

    HTML:

    <select name="depApt" id="depApt">
      <option>&nbsp;</option>
      <option value="A1">Airport One</option>
      <option value="A2">Airport Two</option>
      <option value="A3">Airport Three</option>
    </select>
    
    <select name="dstApt" id="dstApt">
      <option>&nbsp;</option>
      <option value="A1">Airport One</option>
      <option value="A2">Airport Two</option>
      <option value="A3">Airport Three</option>
    </select>
    

    PS: I’ve removed all the IDs of the options as they are not required for my codes, restore it back if needed.

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

Sidebar

Ask A Question

Stats

  • Questions 296k
  • Answers 296k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the .html jQuery method to set HTML contents. <?php… May 13, 2026 at 7:08 pm
  • Editorial Team
    Editorial Team added an answer I'm surprised that you say that the binding itself works… May 13, 2026 at 7:08 pm
  • Editorial Team
    Editorial Team added an answer Well, I'm going to re-format this a bit to help… May 13, 2026 at 7:08 pm

Related Questions

An extension to my previous question: Text cleaning and replacement: delete \n from a
I am generating some text to be shown on a web-site, and use HttpUtility.HtmlEncode
I am currently running into a problem where an element is coming back from
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I am currently scraping some data from the internet and converting into xml documents.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.