giarcjc
07-20-2009, 02:54 PM
1) Script Title: Animated Collapsible DIV
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm#newattrs
3) Describe problem:
I am still kind of a javascript newbie so this is probably a bonehead error on my part, but I'm hoping someone can explain what I'm doing wrong here.
I am using the animated collapse script on various pages, some with only one or two collapsing divs and some pages with up to 40 or more divs. The script is working fine in all browsers that I've tested it in (FF3, IE8, Opera9, Safari4) but I get 1 error message that "divobj is undefined" in FF and IE says "'id' is null or not an object".
This is my code:
for (var i=1; i<=50; i++){
animatedcollapse.addDiv('v'+i, 'fade=1,')
}
animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
//$: Access to jQuery
//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
//state: "block" or "none", depending on state
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "http://www.cjcraig.com/images/selected_open.gif" :"http://www.cjcraig.com/images/selected_closed.gif" ;
}
animatedcollapse.init()
You can see my example pages here:
a few divs:
http://www.cjcraig.com/collapsible_div_test1.html
a lot of divs:
http://www.cjcraig.com/collapsible_div_test2.html
I'm guessing the problem is with this part document.getElementById(divobj.id+"-toggle").src=(state=="block")? "http://www.cjcraig.com/images/selected_open.gif" :"http://www.cjcraig.com/images/selected_closed.gif" ;
Do I have to define every single div here? If so, what's the best way to do that to allow for the varying number of divs on each page? Thanks!
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm#newattrs
3) Describe problem:
I am still kind of a javascript newbie so this is probably a bonehead error on my part, but I'm hoping someone can explain what I'm doing wrong here.
I am using the animated collapse script on various pages, some with only one or two collapsing divs and some pages with up to 40 or more divs. The script is working fine in all browsers that I've tested it in (FF3, IE8, Opera9, Safari4) but I get 1 error message that "divobj is undefined" in FF and IE says "'id' is null or not an object".
This is my code:
for (var i=1; i<=50; i++){
animatedcollapse.addDiv('v'+i, 'fade=1,')
}
animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
//$: Access to jQuery
//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
//state: "block" or "none", depending on state
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "http://www.cjcraig.com/images/selected_open.gif" :"http://www.cjcraig.com/images/selected_closed.gif" ;
}
animatedcollapse.init()
You can see my example pages here:
a few divs:
http://www.cjcraig.com/collapsible_div_test1.html
a lot of divs:
http://www.cjcraig.com/collapsible_div_test2.html
I'm guessing the problem is with this part document.getElementById(divobj.id+"-toggle").src=(state=="block")? "http://www.cjcraig.com/images/selected_open.gif" :"http://www.cjcraig.com/images/selected_closed.gif" ;
Do I have to define every single div here? If so, what's the best way to do that to allow for the varying number of divs on each page? Thanks!