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 3 of 3

Thread: getelementbyid?

  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    getelementbyid?

    Does the below code look correct. I have a <DIV id='sql2'> in my page but the below code does not execute if that elementid is present. What am I doing wrong??

    function allPrint(){
    if (document.getelementbyid('sql2')){
    sql2.style.overflow = "visible";
    window.print();
    sql2.style.overflow = "auto";
    } else{
    doprint();
    }
    }

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    document.getElementById(); case sensative.

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nikko50
    What am I doing wrong??
    JS is case sensitive and you also need to reference your objects properly. the following is the corrected code:

    Code:
    function allPrint()
    {
    	if (sql2=document.getElementById('sql2'))
    	{
    		sql2.style.overflow = "visible";
    		window.print();
    		sql2.style.overflow = "auto";
    	} 
    	else doprint();
    }
    Last edited by jbot; 01-27-2005 at 03:06 PM.
    *keep it simple (TM)


  •  

    Posting Permissions

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