FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Need help with my Blog sidebar

 


Animal
Hi guys, girls and Javascript experts!

I'm looking for some help with my blog. I want the tabs in the sidebar to be expanded by default, but am completely incapable of sorting out the code myself. I had a word with Mathiaus who very helpfully pointed out that the thing that I probably needed to edit was the javascript code. I believe it's somewhere in the following:

Code:
function initit(list, img, stylesheetpath)
{
      var show = GetCookie(list);
var listElementStyle=document.getElementById(list).style;
      if (show == "true"){
                   document.getElementById(img).src = stylesheetpath + "/img/up_light.gif"
                   listElementStyle.display="block";
      }
      else{
document.getElementById(img).src = stylesheetpath + "/img/down_light.gif"
                   listElementStyle.display="none";
      }

}

(Full code available here if needed)

Does anyone have any suggestions as to if and how I could achieve this?

Thanks for any input you can offer! Very Happy
Traveller
Animal wrote:
Code:
function initit(list, img, stylesheetpath)
{
      var show = GetCookie(list);
var listElementStyle=document.getElementById(list).style;
      if (show == "true"){
                   document.getElementById(img).src = stylesheetpath + "/img/up_light.gif"
                   listElementStyle.display="block";
      }
      else{
document.getElementById(img).src = stylesheetpath + "/img/down_light.gif"
                   listElementStyle.display="none";
      }

}


If I'm not mistaken, the following changes should do it:
Code:
function initit(list, img, stylesheetpath)
{
      var show = GetCookie(list);
var listElementStyle=document.getElementById(list).style;

                   document.getElementById(img).src = stylesheetpath + "/img/up_light.gif"
                   listElementStyle.display="block";
                   SetCookie(list,"true");
}


Simply stated, the changes are:
  • Assume that "show" is "true".
  • Remove the '(show == "true")' test.
  • Remove the closing brace of the test.
  • Remove the "else" clause of the test.
  • Add the setting of the cookie to say that selection is shown and expanded (code borrowed from the "switchit()" function in the full source code).
Animal
Hi Traveller, and thanks very much for your input!

This actually did work, and it offers a level of functionality that I would accept. However, the chnges to the javascript stop the menus from minimizing - ie. they are always expanded and clicking the button to close them no-longer works.

Do you know of any way to fix this that isn't too complex? (If not, it isn't a problem - I will just leave the menus expanded)

Thanks again for your help Very Happy
Traveller
Animal wrote:
However, the chnges to the javascript stop the menus from minimizing - ie. they are always expanded and clicking the button to close them no-longer works.

Do you know of any way to fix this that isn't too complex?

That seems odd. You didn't remove the switchit() function, did you?

If not, then maybe the call to SetCookie that I included is causing the problem.

Could you provide a link to the edited code, or paste it here so I may look at it for comparison? I tried your actual site, and the link you posted for the original source, but they don't appear to have the changes.
mathiaus
Go on then, I'm going to have a guess now. Couldn't resist Smile
Code:
function initit(list, img, stylesheetpath)
{
var show = GetCookie(list);
var listElementStyle=document.getElementById(list).style;
   if (show == "true"){
      document.getElementById(img).src = stylesheetpath + "/img/up_light.gif"
         listElementStyle.display="block";
   }
   else if (show == "false"){
      document.getElementById(img).src = stylesheetpath + "/img/down_light.gif"
      listElementStyle.display="none";
   }
   else {
      document.getElementById(img).src = stylesheetpath + "/img/up_light.gif"
      listElementStyle.display="block";
   }

}

I checked this myself as well to make sure it works (which it does Wink )
Animal
Traveller, thank you very much for your input - it was very helpful. Mathiaus, you're right - it's now working perfectly!

Thank you both very much for the help on this - it now seems to be working exactly as I want it to Very Happy

This is resolved, so -close-
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.