Help - Search - Members - Calendar
Full Version: Passing Variables With ' And Without
Zymic Webmaster Forums > Web Design & Development > Client Side Scripting > JavaScript
ElenaDD
Hello,

When I pass variables 'contentA','contentB','contentC', etc... into the tabs() function, it does not work in Internet Explorer.
When I pass variables contentA,contentB,contentC, etc... into the tabs() function, it works perfectly in Internet Explorer but not in firefox!!!!

This is the last bug that I need to fix in my site - and it'll be ready (after having beed doing it for 2 months). I think this is the last web site I'm building manually - too much stress and time consuming. I'll do all my web sites from now on in Dreamweaver, with just minimal coding. I think there are more practical things in daily life and career planning to think about, than getting stuck in some javascript bugs, etc, for days, don't you think so? Although I love creating web pages. And I admire the guys who make their living on programming in php, javascript, etc.

Can anybody help me with this?
Thanks.



CODE
<script language="JavaScript" type="text/JavaScript">
<!--

function tabs(view,hideA,hideB,hideC,hideD,colourid1, colourid2, colourid3, colourid4, colourid5) {

   if (view.style.visibility == "hidden") {
  view.style.visibility = "visible";
  view.style.display = "block";
  hideA.style.visibility = "hidden";
  hideB.style.visibility = "hidden";
  hideC.style.visibility = "hidden";
  hideD.style.visibility = "hidden";
  hideA.style.display = "none";
  hideB.style.display = "none";
  hideC.style.display = "none";
  hideD.style.display = "none";
    }else{
        view.style.visibility = "hidden";
        view.style.display = "none";
    
    
      }  
}


//-->
</script>
</head>

<body>

<ul>
            <li><a href="java script:void(0);" onClick="tabs('contentA','contentB','contentC','contentD','contentE','originalcolourA')" id="originalcolourA"><b>Colour</b></a></li>
<li><a href="java script:void(0);" onClick="tabs('contentB','contentA','contentC','contentD','contentE','originalcolourB','originalcolourA','originalcolourC','originalcolourD','originalcolourE')" id="originalcolourB"><b>Feeding</b></a></li>
            <li><a href="java script:void(0);" onClick="tabs('contentC','contentA','contentB','contentD','contentE','originalcolourC','originalcolourA','originalcolourB','originalcolourD','originalcolourE')" id="originalcolourC"><b>Breeding</b></a></li>
            <li><a href="java script:void(0);" onClick="tabs('contentD','contentA','contentB','contentC','contentE','originalcolourD','originalcolourA','originalcolourB','originalcolourC','originalcolourE')" id="originalcolourD"><b>Voice</b></a></li>
            <li><a href="java script:void(0);" onClick="tabs('contentE','contentA','contentB','contentC','contentD','originalcolourE','originalcolourA','originalcolourB','originalcolourC','originalcolourD')" id="originalcolourE"><b>Location</b></a></li>
</ul>

<div id="contents">
<div id="contentA" style="visibility: hidden;"><p id="contentAA"></p></div>
<div id="contentB" style="visibility: hidden;"><p id="contentBB"></p></div>
<div id="contentC" style="visibility: hidden;"><p id="contentCC"></p></div>
<div id="contentD" style="visibility: hidden;"><p id="contentDD"></p></div>
<div id="contentE" style="visibility: hidden;"><p id="contentEE"></p></div>
</div>
  

</body>
Ed
Using an element name as an object is bad form, you need to 'getElementById' to return the correct DOM node:

CODE
function geid(id)
{
   return document.getElementById(id);
}

function tabs(view,hideA,hideB,hideC,hideD,colourid1, colourid2, colourid3, colourid4, colourid5) {
   if (geid(view).style.visibility == "hidden") {
      geid(view).style.visibility = "visible";
      geid(view).style.display = "block";
      geid(hideA).style.visibility = "hidden";
      geid(hideB).style.visibility = "hidden";
      geid(hideC).style.visibility = "hidden";
      geid(hideD).style.visibility = "hidden";
      geid(hideA).style.display = "none";
      geid(hideB).style.display = "none";
      geid(hideC).style.display = "none";
      geid(hideD).style.display = "none";
   }else{
      geid(view).style.visibility = "hidden";
      geid(view).style.display = "none";
   }
}


This should fix your issues smile.gif
ElenaDD
Bread, Thank you so much! It worked
Ed
QUOTE(ElenaDD @ Sep 13 2008, 07:41 PM) *
Bread, Thank you so much! It worked


No problem cool.gif

Good luck with the site.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.