Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<SELECT> dropdowns with inherited or hidden visibility cause problems #19

Open
GoogleCodeExporter opened this issue Jun 2, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Scott's fix for IE6 to hide and then show <SELECT> fields causes problems 
when the current visibility of the object is 'inherit' or 'hidden'.

E.g. the dropdown is on a div layer that is currently hidden (a menu pane 
for example).  The visibility value of the dropdown will be 'inherit' i.e. 
it inherits the value of it's parent.  Scott's fix hides the dropdown but 
then sets it to visible when the modal window is closed.  This results in 
the dropdown then being visible when it shouldn't be.

I've fixed this by storing the visibility property for each SELECT field 
in hideSelectBoxes() and then restoring it to its previous value in 
displaySelectBoxes().



var gSelectArray;

function hideSelectBoxes() {
  var x = document.getElementsByTagName("SELECT");
  gSelectArray = new Array();

  for (i=0;x && i < x.length; i++) {
    /* .currentStyle property is IE only but this shouldn't be a problem 
here */
    switch (x[i].currentStyle.visibility) {
        case "hidden" :
            gSelectArray[i] = 0;
            break;
        case "visible" :
            gSelectArray[i] = 1;
            x[i].style.visibility = "hidden";
            break;
        case "inherit" :
            gSelectArray[i] = 2;
            x[i].style.visibility = "hidden";
            break;
    }
  }
}

function displaySelectBoxes() {
  var x = document.getElementsByTagName("SELECT");

  for (i=0;x && i < x.length; i++){
    switch (gSelectArray[i]) {
        case 0:
            x[i].style.visibility = "hidden";
            break;
        case 1: 
            x[i].style.visibility = "visible";
            break;
        case 2:
            x[i].style.visibility = "inherit";
            break;
    }
  }
}

Original issue reported on code.google.com by gmail%ac...@gtempaccount.com on 21 May 2009 at 9:44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant