Hi, i have this jscript code and I want to show the first div onLoad. Trying to figure this out, what I did was:
<body onload="showdiv(0);">
Running on firefox works fine, the first div is showing onload BUT testing on IE doesn't work at all. It displays an error:
document.getElementById()is null or not an object
here's the jscript i'm using:
<script type="text/javascript">
var c;
var k=0;
var j=0;
var ary=[];
var divs=document.getElementsByTagName('div');
var lnks=document.getElementsByTagName('a');
var splt;
function init() {
for(c=0;c<divs.length;c++) {
if(divs[c].className=='show') {
divs[c].className='hide';
divs[c].id='d'+k++;
}
}
for(c=0;c<lnks.length;c++) {
if(lnks[c].className=='hide') {
ary[c]=true;
lnks[c].className='hs';
lnks[c].id='a'+j++;
lnks[c].onclick=function() {
splt=this.id.split('a')[1];
if(ary[splt]==true) {
this.firstChild.nodeValue='hide '+(parseFloat(splt)+1);
ary[splt]=false;
showdiv(splt);
return false;
}
else {
this.firstChild.nodeValue='show '+(parseFloat(splt)+1);
ary[splt]=true;
document.getElementById('d'+splt).className='hide' ;
return false;
}
}
}
}
}
function showdiv(num) {
for(c=0;c<j;c++){
document.getElementById('a'+c).firstChild.nodeValu e='show '+(c+1);
document.getElementById('a'+num).firstChild.nodeVa lue='hide '+(parseFloat(num)+1);
ary[c]=true;
ary[num]=false;
}
for(c=0;c<divs.length;c++) {
if(divs[c].className=='show') {
divs[c].className='hide';
}
}
document.getElementById('d'+num).className='show';<--- this is the line error
}
if(window.addEventListener){
window.addEventListener('load',init,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',init);
}
}
</script>
How will i solve this issue? So frustrating...

Hope someone can take a peek on my codes.