Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    71
    Thanks
    9
    Thanked 0 Times in 0 Posts

    getElementById has no properties in FF?

    I have been struggling with following code. I can't get it to work. Please help. Thanks.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function showhide(x) {
       var el = id(x);
       el.style.display=(el.style.display=='block')?'none':'block';
       var y='<input name=a value=name onclick="return showIQ(' + "'89499F50000'" + ');">';
    
       document.getElementById(x).innerHTML = y;
       return false;
    }
    
    function showIQ(stkid) {
       var stk = stkid.slice(0,5);
       var x = 'S'+stkid.slice(6);
       var el = id(x);
       el.style.display=(el.style.display=='block')?'none':'block';
       return false;
    }
    
    function id(x) {                                                 
       if (typeof x == "string") return document.getElementById(x);  
       return x;                                                     
    }                                                                
    
    </script>
    
    </head>
    
    <body>
    
    <a href="#" onclick="return showhide('F50000');">NAMES</a><br>
    <div id="F50000" style="display:none;">
      <div id="S50000" style="display:none;">ROBERT</div>
    </div>
    
    </body>
    
    </html>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    using innerHTML

    <div id="S50000" >ROBERT</div>

    has been replaced by the input
    var y='<input name=a value=name onclick="return showIQ(' + "'89499F50000'" + ');">';

    and no longer exists
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New Coder
    Join Date
    Nov 2007
    Posts
    71
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks. How can I achieve same result? adding to innerHTML?

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    adding to innerHTML?
    Yes or

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function showhide(x) {
       var el = id(x);
       el.style.display=(el.style.display=='block')?'none':'block';
       var y=document.createElement('INPUT');
       y.type='text';
       y.name='a';
       y.value='name';
       y.onclick=function(){ return showIQ('89499F50000');  }
       var obj=document.getElementById('F50000');
       obj.parentNode.insertBefore(y,obj);
       return false;
    }
    
    function showIQ(stkid) {
       var stk = stkid.slice(0,5);
       var x = 'S'+stkid.slice(6);
       var el = id(x);
       el.style.display=(el.style.display=='block')?'none':'block';
       return false;
    }
    
    function id(x) {
       if (typeof x == "string") return document.getElementById(x);
       return x;
    }
    
    </script>
    
    </head>
    
    <body>
    
    <a href="#" onclick="return showhide('F50000');">NAMES</a><br>
    <div id="F50000" style="display:none;">
      <div id="S50000" style="display:none;">ROBERT</div>
    </div>
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #5
    New Coder
    Join Date
    Nov 2007
    Posts
    71
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thank you vic for your valuable time.

  • #6
    New Coder
    Join Date
    Nov 2007
    Posts
    71
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Overlapping?

    Vic, I have a question on overlapping. Second DIV should be overlapped on first DIV. In this example, 2nd shows below the first one.

    Thanks.

  • #7
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function showhide(x) {
       var el = id(x);
       el.style.display=(el.style.display=='block')?'none':'block';
       var y=document.createElement('INPUT');
       y.type='text';
       y.name='a';
       y.value='name';
       y.onclick=function(){ return showIQ('89499F50000');  }
       var obj=document.getElementById('F50000');
       obj.parentNode.insertBefore(y,obj);
       return false;
    }
    
    function showIQ(stkid) {
       var stk = stkid.slice(0,5);
       var x = 'S'+stkid.slice(6);
       var el = id(x);
       el.style.display=(el.style.display=='block')?'none':'block';
       return false;
    }
    
    function id(x) {
       if (typeof x == "string") return document.getElementById(x);
       return x;
    }
    
    </script>
    
    </head>
    
    <body>
    
    <a href="#" onclick="return showhide('F50000');">NAMES</a><br>
    <div id="F50000" style="display:none;">
      <div id="S50000" style="position:relative;left:0px;top:-45px;display:none;">ROBERT</div>
    </div>
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •