Using "visibility" style attribute with select elements

Discussion in 'Javascript' started by Dave Hammond, Feb 18, 2005.

  1. Dave Hammond

    Dave Hammond Guest

    I'm not sure if this is technically a javascript question, but I'm
    coding in javascript, so I'll try here first.

    To overlay a section of a page I typically use an absolute positioned
    <div> and call insertAdjacentHTML. By raising the z-index higher than
    than the underlying elements this method works fine, except if there is
    a window'd element below it, such as a <select>. My understanding is
    that I need to use the visbility attribute to hide the <select> before
    calling insertAdjacentHTML.

    Each <select> element (there are three) is identified with the ID
    "select_vis". I am attempting to hide the select elements using the
    following code:

    selvis = document.getElementById('select_vis');
    if (selvis) {
    alert('gonna hide the selects.');
    selvis.style.visibility = 'hidden';
    }
    document.body.insertAdjacentHTML('BeforeEnd', theHTML);

    The code is being executed, however the three selects stay visible. Any
    suggestions/observations would be greatly appreciated.

    Thanks,
    Dave H.
     
    Dave Hammond, Feb 18, 2005
    #1
    1. Advertising

  2. Dave Hammond

    Dave Hammond Guest

    Solved the problem...

    After a bit closer examination, I found that the first select was
    hidden, but all others remained visible. I changed the code so that
    all selects have individual IDs and now everything hides as expected.

    Thanks.
    -Dave H.
     
    Dave Hammond, Feb 18, 2005
    #2
    1. Advertising

  3. Re: Solved the problem...

    Dave Hammond wrote:

    > After a bit closer examination, I found that the first select was
    > hidden, but all others remained visible.


    That's the expected behaviour.

    > I changed the code so that all selects have individual IDs [...]


    Good. Every id in a document /must/ be unique. You would have found
    that had you validated the mark-up.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Feb 18, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,098
    Henry S. Thompson
    Mar 6, 2006
  2. Kevin Frey
    Replies:
    0
    Views:
    418
    Kevin Frey
    Jul 28, 2006
  3. Stefan_W
    Replies:
    1
    Views:
    8,387
    Stefan_W
    Nov 5, 2008
  4. Tim Streater
    Replies:
    2
    Views:
    402
    Tim Streater
    Jul 11, 2011
  5. Tim Streater
    Replies:
    24
    Views:
    254
    dhtml
    Jul 18, 2011
Loading...

Share This Page