I am having some problems passing objects between functions. Please look at the code below and tell me where I'm going wrong.
description: I am calling checkAns with the following variables set:
checkAns("secCover1",5,5)
checkAns is calling setAction which is calling fadeOut which is calling setOpacity.
In setOpacity you can see the alert I have setup for testing purposes and I am getting "null - 100" as the alert when it's executed.
function changeZ(secID,newZ){
secID.style.zIndex = newZ;
}
function checkAns(secID,nUser,nCorr){
objID = secID;
if(nUser == nCorr){
setAction(objID,"out");
}
}
function setAction(secID,fadeType) {
objID = secID;
if(fadeType == "in"){
fadeIn(objID,0);
} else {
fadeOut(objID,100);
}
}
function fadeIn(secID,opacity){
if (document.getElementById){
objID = document.getElementById(secID);
if (opacity <= 100) {
setOpacity(objID, opacity);
opacity += 10;
window.setTimeout("fadeIn('"+objID+"',"+opacity+")", 100);
}
}
}
function fadeOut(secID,opacity){
if (document.getElementById){
objID = document.getElementById(secID);
if (opacity > 0) {
setOpacity(objID, opacity);
opacity -= 10;
window.setTimeout("fadeOut('"+objID+"',"+opacity+")", 100);
}
}
}
function setOpacity(secID, opacity) {
alert(secID + ' - ' + opacity);
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
secID.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
secID.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
secID.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
secID.style.opacity = opacity/100;
}
'
Thanks for your help.






Abhishek Reddy posted this at 17:01 — 20th May 2005.
He has: 3,303 posts
Joined: Jul 2001
I can't tell straight away what's going wrong. Got a link to a test page with the rest of the code?
abhishek.geek.nz
artsapimp posted this at 17:06 — 20th May 2005.
They have: 330 posts
Joined: Apr 2000
No, it's on my internal server that is behind a corporate firewall.
With all of my changes I have narrowed the problem to 1 thing. Looking at my code below, when I specify secCover1 as the objID it works fine. When I alert secID it displays secCover1. When I specify objID = secID it fails. That doesn't make much sense to me.
Any help would be greatly appreciated.
Free Math Test
Fun Math Games
artsapimp posted this at 17:07 — 20th May 2005.
They have: 330 posts
Joined: Apr 2000
function fadeOut(secID){alert(secID);
objID = secCover1;
nOpac = objID.filters.alpha.opacity;
if (nOpac > 0) {
nOpac -= 10
objID.filters.alpha.opacity = nOpac;
window.setTimeout("fadeOut(objID.id)",50);
}
}
'
Free Math Test
Fun Math Games
Abhishek Reddy posted this at 17:18 — 20th May 2005.
He has: 3,303 posts
Joined: Jul 2001
Try using secID here, since you're guaranteed to keep the same input:
window.setTimeout("fadeOut(" + secID + ")",50);
Without being able to go through a debugging process, I'm taking shots in the dark.
abhishek.geek.nz
artsapimp posted this at 17:23 — 20th May 2005.
They have: 330 posts
Joined: Apr 2000
Thank you for your help. Below is the final code that is working.
function fadeOut(secID){//alert(secID);
objID = document.getElementById(secID);
nOpac = objID.filters.alpha.opacity;
if (nOpac > 0) {
nOpac -= 10
objID.filters.alpha.opacity = nOpac;
window.setTimeout("fadeOut('" + secID + "')",50);
}
}
'
Free Math Test
Fun Math Games