•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,490 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,670 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1312 | Replies: 6
![]() |
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 1
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
The code is from here:
http://www.harrymaugans.com/2007/03/...cript-and-css/
And here:
http://www.harrymaugans.com/2007/03/...-animated-div/
I can't see a solution in the comments on the page anywhere.
Thanks for any help you can give.
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
javascript Syntax (Toggle Plain Text)
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:
http://www.harrymaugans.com/2007/03/...cript-and-css/
And here:
http://www.harrymaugans.com/2007/03/...-animated-div/
I can't see a solution in the comments on the page anywhere.
Thanks for any help you can give.
Last edited by rickya100 : Jun 4th, 2008 at 7:32 pm. Reason: code syntax
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 1
OK so the error above is no longer happening but an error that keeps replicating s now happening and it eventually crashes the browser.
It's on line 77 and it says "Type Error, Undefined Value"
An example of the site is online at www.mctc.co.uk
It's on line 77 and it says "Type Error, Undefined Value"
An example of the site is online at www.mctc.co.uk
Last edited by rickya100 : Jun 4th, 2008 at 9:18 pm. Reason: Added web address
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 1
•
•
•
•
You can't call a function that is below the function you call it from. Move endSlide up above slidetick.
Hi MidiMagic,
Thanks for the reply. I did as you said and now I get an error of "Undefined Error" in FireFox's control panel. It again keeps replicating without stopping until I close the page.
It flags the following line in slideTick as the problem:
php Syntax (Toggle Plain Text)
obj[objname].style.height = d + "px";
Any thoughts on this?
This depends on what is in the object module at the time the script loads. Scripts can not see dynamic changes made to web pages, unless the script is keeping track of the changes it makes itself.
Whether a script can see the style depends on when the script starts.
Whether a script can see the style depends on when the script starts.
Daylight-saving time uses more gasoline
•
•
Join Date: Mar 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 1
•
•
•
•
This depends on what is in the object module at the time the script loads. Scripts can not see dynamic changes made to web pages, unless the script is keeping track of the changes it makes itself.
Whether a script can see the style depends on when the script starts.
Sorry, I don't quite understand what you're saying.
Could you try and explain it again please. I'm not very experienced in JavaScript but I do a few other languages PHP etc so I'm comfortable with all the concepts. It's just the specific rules and syntax of JavaScript I stumble over sometimes.
Thank you.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: dhtml flicker
- Next Thread: Two Submit Buttons -- One PHP Destination



Linear Mode