Hi, thanks for checking this out.
Ok so the problem is that I have the following code for trying to get a div to slide down from the top of my page.
The problem is that on clicking the button that activates the function I get an error.
The error is flagged at line number 23 as an Undefined Value.
the javascript is below
var timerlen = 5;
var slideAniLen = 5000;
var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();
function toggleSlide(objname){
if(document.getElementById(objname).style.display == "none"){
// div is hidden, so let's slide down
if (objname == 'login'){
document['objname'].src = "images/member_login_btn_go_up";
}
alert(objname);
slideshow(objname);
}else{
// div is not hidden, so slide up
if (objname == 'login'){
document['objname'].src = "images/member_login_btn_go_down";
}
slidehide(objname);
}
}
function slideshow(objname){
if (moving[objname]){
return;
}
if (document.getElementById(objname).style.display != "none"){
return;
}
moving[objname] = true;
dir[objname] = "down";
startslide(objname);
}
function slidehide(objname){
if ( moving[objname]){
return;
}
if (document.getElementById(objname).style.display == "none"){
return;
}
moving[objname] = true;
dir[objname] = "up";
startslide(objname);
}
function startslide(objname){
obj[objname] = document.getElementById(objname);
endHeight[objname] = parseInt(obj[objname].style.height);
startTime[objname] = (new Date()).getTime();
if (dir[objname] == "down"){
obj[objname].style.height = "1px";
}
obj[objname].style.display = "block";
timerID[objname] = setInterval('slidetick(" + objname + ");',timerlen);
}
function slidetick(objname){
var elapsed = new Date().getTime() - startTime[objname];
if (elapsed > slideAniLen){
endSlide(objname);
}
else {
var d = Math.round(elapsed / slideAniLen * endHeight[objname]);
if(dir[objname] == "up"){
d = endHeight[objname] - d;
}
obj[objname].style.height = d + "px";
}
return;
}
function endSlide(objname){
clearInterval(timerID[objname]);
if (dir[objname] == "up")
obj[objname].style.display = "none";
obj[objname].style.height = endHeight[objname] + "px";
delete(moving[objname]);
delete(timerID[objname]);
delete(startTime[objname]);
delete(endHeight[objname]);
delete(obj[objname]);
delete(dir[objname]);
return;
}
The code is from here:
And here:
http://www.harrymaugans.com/2007/03/24/one-click-toggle-for-sliding-animated-div/
I can't see a solution in the comments on the page anywhere.
Thanks for any help you can give.