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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:15:13+00:00 2026-05-28T17:15:13+00:00

I’m using the following HTML/JS code to display a 2nd dropdown menu below the

  • 0

I’m using the following HTML/JS code to display a 2nd dropdown menu below the first dropdown.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">    
<head> 
<!-- Title --> 
<title>Test</title>  
<!-- --> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
<meta http-equiv="Content-Language" content="en-gb" /> 
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript">
    function switchStates(obj) {    
        if (obj.selectedIndex==14){document.getElementById('ddlCollectionStatesUSA').style.visibility='visible'}else {document.getElementById('ddlCollectionStatesUSA').style.visibility='hidden'};

        if (obj.selectedIndex==2){document.getElementById('ddlCollectionStatesIRL').style.visibility='visible'}else {document.getElementById('ddlCollectionStatesIRL').style.visibility='hidden'};

        if (obj.selectedIndex==15){document.getElementById('ddlCollectionStatesCAN').style.visibility='visible'}else {document.getElementById('ddlCollectionStatesCAN').style.visibility='hidden'};

        if(document.getElementById('qq_deliverycountry').selectedIndex != 0) {document.getElementById('qq_collectioncountry').disabled = true;}else {document.getElementById('qq_collectioncountry').disabled = false;}     

    }
</script>
</head>
<body>                    

<form action="#" method="post">                        
<fieldset> 
  <h3>Delivery Details</h3>                        
  <div class="inputs"> 
   <label for="qq_deliverycountry">Country</label> 
   <select id="qq_deliverycountry" name="dcountry" onchange="switchStates(this)">                               
        <option selected="selected" value="GBR">United Kingdom (Mainland)</option>
        <option value="">--------------------</option>
            <option value="IRL">Republic of Ireland</option>                        
        <option value="GGY">Channel Islands (Guernsey)</option>
        <option value="JEY">Channel Islands (Jersey and Sark)</option>  
            <option value="NIR">Northern Ireland</option>
        <option value="">--------------------</option>
        <option value="FRA">France</option>
        <option value="DEU">Germany</option>
        <option value="ITA">Italy</option>
        <option value="POL">Poland</option>
        <option value="PRT">Portugal</option>
        <option value="ESP">Spain</option>
        <option value="AUS">Australia</option>
            <option value="USA">United States of America</option>
        <option value="CAN">Canada</option>
        <option value="CHN">China</option>
   </select> 
  </div>                              
<div>

<label for="ddlCollectionStatesUSA">State/Province</label>
    <select name="ddlCollectionStatesUSA" id="ddlCollectionStatesUSA" class="ddList" style="position: relative; top: 0; left: 0; visibility: hidden; border-color: default;">
        <option selected="selected" value=""></option>
        <option value="Alabama">Alabama</option>
        <option value="Alaska">Alaska</option>
    </select>
    <select name="ddlCollectionStatesCAN" id="ddlCollectionStatesCAN" class="ddList"
        style="position: relative; top: 0; left: 0; border-color: default; visibility: hidden;">
        <option selected="selected" value=""></option>
        <option value="Alberta">Alberta</option>
        <option value="Britich Columbia">Britich Columbia</option>
    </select>
    <select name="ddlCollectionStatesIRL" id="ddlCollectionStatesIRL" class="ddList" style="position: relative; top: 0; left: 0; border-color: default; visibility: hidden;">
        <option selected="selected" value=""></option>
        <option value="Antrim">Antrim</option>
        <option value="Armagh">Armagh</option>
    </select>
    </div><!-- end of states container -->
    </div> 
    </fieldset> 
   </form> 
  </div> 
 </body> 
</html>

It works brilliantly so if I select USA, Canada or Ireland it will show the relevant states/provinces underneath.

My only issue is if I select Ireland or Canada the 2nd dropdown displays a little to the right instead of exactly where the USA dropdown appears (i.e. directly underneath first dropdown).

How do I fix this?

Many thanks for your input here.

  • 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-28T17:15:14+00:00Added an answer on May 28, 2026 at 5:15 pm

    Swap out the visibility='hidden' for display='none'.

    The visibility setting hides the element but it still takes up space on the page. Using display will reclaim the space in the document flow allowing all the drop down to appear right next to the label as the other dropdowns are not in the way.

    Example: http://jsfiddle.net/Z82Wz/

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker
I have this code to decode numeric html entities to the UTF8 equivalent character.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is

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.