Forum Moderators: open

Message Too Old, No Replies

Help with Toggle Script

need to make it default to visible ---not hidden

         

rose1212

7:02 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



I wanted to see if you could help me with this script. I am working on a new function for this toggle script.
At this time, the script defaults is set to hide content.
I want to change it to default visible so we can use the script for some pages that we want to show the content at page load.

Here is the URL of a working script so you get a visual:
[gis.esri.com...]

Thanks for any help you can give.

/*---------------------------------------
TESTING TOGGLE SCRIPT
---------------------------------------*/

//use this to collapse/expand lists
function toggle(thisList){
if (document.getElementById(thisList).style.display =="") {
document.getElementById(thisList).style.display = "block";
document.getElementById(thisList + "arrow").className = "selectedCategory";
} else {
document.getElementById(thisList).style.display ="";
document.getElementById(thisList + "arrow").className = "arrow";
}
}

//use this to "show" or "hide" all the things on a collapsable list, at the same time

function toggleAllTag(tagname) {
tagArray = document.getElementsByTagName(tagname);
// produces an array of all objects in the page that are the tag you requested
for (i = 0; i < tagArray.length; i ++) {
if (tagState == "hidden") {
document.getElementById(tagArray[i].id).style.display = "block";
document.getElementById(tagArray[i].id + "arrow").className = "selectedCategory";
} else {
document.getElementById(tagArray[i].id).style.display ="";
document.getElementById(tagArray[i].id + "arrow").className = "arrow";
}
}
tagState = (tagState == "hidden")? "visible" : "hidden";
}
//for some reason the down arrow won't show unless it's preloaded.
var downArrow = new Image();
downArrow.src = "/graphics/sidenavarrowdown.gif";
var rightArrow = new Image();
rightArrow.src = "/graphics/sidenavarrow.gif";
var blueBullet = new Image();
blueBullet.src = "/graphics/sidenavbullet.gif";

//tagState must be defined
tagState = "hidden";

whoisgregg

5:57 am on Mar 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your script is just checking the current state then toggling it to the other.

To change the default, you need to edit the CSS that defines the element in the first place. Just make your CSS start as "display:block;" instead of "display:none;" and you'll be all set.

Added: Where are my manners!

Welcome to WebmasterWorld, rose1212!

I'm sure you'll enjoy how helpful this forum is. Also, for future posts, the forum charter [webmasterworld.com] restricts the posting of personal URLs. :)

rose1212

9:03 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Thank you for your Welcome. I see a lot of helpful people on this board. I'm glad I found it.

Thank you for your help.