I have the following onload function:
[HTML]function slidebarPrep(){
if(!document.ge tElementById) return false;
var slidebar = document.getEle mentsByTagName( "div");
for(var i = 0; i < slidebar.length ; i++){
if(slidebar[i].className == "sub_slidebar") {
var parentId = slidebar[i].offsetParent.i d;
var parentHeight = slidebar[i].offsetParent.c lientHeight;
var subBox = document.getEle mentById(parent Id);
subBox.style.he ight = "115px";
slidebar[i].onclick = function(){
sub_expand(50, parentId, parentHeight);
}
}
}
}[/HTML]
I have three div's with parent Id's of submitNews, podcastTopic and VideoSubmission s. So when slidebar[i].onclick I would expect it to output like this:
onclick="sub_ex pand(50, submitNews, 531);"
onclick="sub_ex pand(50, podcastTopic, 600);"
onclick="sub_ex pand(50, videoSubmission s, 425);"
However for some reason each onclick is set to:
onclick="sub_ex pand(50, videoSubmission s, 425);"
The last div in the loop.
However everything else is set correctly prior to the onclick portion, i.e. each div's hight is set to 115px.
Does anybody have any suggestions?
[HTML]function slidebarPrep(){
if(!document.ge tElementById) return false;
var slidebar = document.getEle mentsByTagName( "div");
for(var i = 0; i < slidebar.length ; i++){
if(slidebar[i].className == "sub_slidebar") {
var parentId = slidebar[i].offsetParent.i d;
var parentHeight = slidebar[i].offsetParent.c lientHeight;
var subBox = document.getEle mentById(parent Id);
subBox.style.he ight = "115px";
slidebar[i].onclick = function(){
sub_expand(50, parentId, parentHeight);
}
}
}
}[/HTML]
I have three div's with parent Id's of submitNews, podcastTopic and VideoSubmission s. So when slidebar[i].onclick I would expect it to output like this:
onclick="sub_ex pand(50, submitNews, 531);"
onclick="sub_ex pand(50, podcastTopic, 600);"
onclick="sub_ex pand(50, videoSubmission s, 425);"
However for some reason each onclick is set to:
onclick="sub_ex pand(50, videoSubmission s, 425);"
The last div in the loop.
However everything else is set correctly prior to the onclick portion, i.e. each div's hight is set to 115px.
Does anybody have any suggestions?
Comment