select list show/hide elements: problems in IE Options

Discussion in 'HTML' started by punnu35@gmail.com, Oct 17, 2007.

  1. Guest

    I am trying to do this simple thing in html. I have a select list and
    when you click the button the first element should hide. It works
    fine
    in firefox but not in IE. I have tried all sorts of things but could
    not do it. Any help...

    <html>
    <body>
    <select id="pid" name="pid" multiple>
    <option id="a" value="a">a</option>
    <option id="b" value="b">b</option>
    <option id="c" value="c">c</option>
    </select>
    <input name="submit" value="Start Analysis" type="button"
    onClick="javascript:show_hide()">
    </body>
    <script type="text/javascript">
    function show_hide() {
    var a = document.getElementById("a");
    a.style.display="none";
    }
    </script>
    </html>
     
    , Oct 17, 2007
    #1
    1. Advertising

  2. Neredbojias Guest

    Well bust mah britches and call me cheeky, on Wed, 17 Oct 2007 22:01:29 GMT
    scribed:

    > I am trying to do this simple thing in html. I have a select list and
    > when you click the button the first element should hide. It works
    > fine
    > in firefox but not in IE. I have tried all sorts of things but could
    > not do it. Any help...
    >
    > <html>
    > <body>
    > <select id="pid" name="pid" multiple>
    > <option id="a" value="a">a</option>
    > <option id="b" value="b">b</option>
    > <option id="c" value="c">c</option>
    > </select>
    > <input name="submit" value="Start Analysis" type="button"
    > onClick="javascript:show_hide()">
    > </body>
    > <script type="text/javascript">
    > function show_hide() {
    > var a = document.getElementById("a");
    > a.style.display="none";
    > }
    > </script>
    > </html>


    Get rid of this:

    var a = document.getElementById("a");
    a.style.display="none";

    and use this instead:

    document.getElementById("a").style.display="none";

    Also, I presume you have a form enclosing the form elements.

    --
    Neredbojias
    Half lies are worth twice as much as whole lies.
     
    Neredbojias, Oct 17, 2007
    #2
    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. Guest
    Replies:
    3
    Views:
    13,536
    Walter Wang [MSFT]
    Jul 27, 2006
  2. Hide / Show form Elements.

    , Sep 8, 2005, in forum: Javascript
    Replies:
    4
    Views:
    173
  3. Replies:
    2
    Views:
    186
  4. ll
    Replies:
    2
    Views:
    669
    Thomas 'PointedEars' Lahn
    May 1, 2008
  5. nick
    Replies:
    21
    Views:
    328
    Jeremy J Starcher
    May 11, 2010
Loading...

Share This Page