...

View Full Version : getelementbyid?



nikko50
01-27-2005, 01:28 PM
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();
}
}

Brandoe85
01-27-2005, 01:56 PM
document.getElementById(); case sensative. :)

jbot
01-27-2005, 02:00 PM
What am I doing wrong??

JS is case sensitive and you also need to reference your objects properly. the following is the corrected code:


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum