zed420 Posted December 22, 2008 Share Posted December 22, 2008 Hi All Can anyone please tell me why doesn't this code work in Firefox. I'm using it for showing and hidding the divs. Woks fine in IE. <script type="text/javascript"><!-- var lastDiv = ""; function showDiv(divName) { // hide last div if (lastDiv) { document.getElementById(lastDiv).className = "hiddenDiv"; } if (divName && document.getElementById(divName)) { document.getElementById(divName).className = "visibleDiv"; lastDiv = divName; } } //--> </script> Thanks Zed Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/ Share on other sites More sharing options...
Adam Posted December 22, 2008 Share Posted December 22, 2008 What does the error console say? A Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-721334 Share on other sites More sharing options...
zed420 Posted December 22, 2008 Author Share Posted December 22, 2008 There are NO errors, it won't hide any of the forms like it should or does in IE. Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-721345 Share on other sites More sharing options...
RichardRotterdam Posted December 22, 2008 Share Posted December 22, 2008 I think lastDiv is the problem. the first time you call it the var lastDiv is empty. have you installed firebug for firefox? Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-721350 Share on other sites More sharing options...
zed420 Posted December 22, 2008 Author Share Posted December 22, 2008 Thanks for your reply, No I haven't installed firebug, should this solve my problem?? Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-721361 Share on other sites More sharing options...
RichardRotterdam Posted December 22, 2008 Share Posted December 22, 2008 It doesn't solve your problem but it can assist you in finding the problem and correcting it. It's a plugin that makes js debugging a whole lot easier Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-721362 Share on other sites More sharing options...
Adam Posted December 22, 2008 Share Posted December 22, 2008 Try adding this .. window.onload = function() { var lastDiv = ""; } instead of just lastDiv = ""; .. A Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-721376 Share on other sites More sharing options...
Mikedean Posted December 23, 2008 Share Posted December 23, 2008 This could also be a CSS issue, what value are you setting 'display' to hide/show the DIV's? Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-722474 Share on other sites More sharing options...
Adam Posted December 23, 2008 Share Posted December 23, 2008 Try adding this .. window.onload = function() { var lastDiv = ""; } instead of just lastDiv = ""; .. A Ignore that! Link to comment https://forums.phpfreaks.com/topic/138004-showhide-div-not-workink-in-ff/#findComment-722491 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.