mpoer Posted February 17, 2006 Share Posted February 17, 2006 I found this javascript that seems to almost do what I want (below). I haven't altered it yet, because it looks like it should work when I mess with the CSS for this. Basically, I want when you click the link for it to show the info, and click again to make it dissapear. I want it to start out hidden, though, hence the css at the bottom of the following code. <script type="text/javascript"><!--// toggle visibilityfunction toggle( targetId ){ if (document.getElementById){ target = document.getElementById( targetId ); if (target.style.display == "none"){ target.style.display = ""; } else { target.style.display = "none"; } }}--></script><style type="text/css">#item01 {display:none;}</style> The page is here: http://thinktank.ichyware.net:81/~matthew/herd/services.phpthe darn thing works without the CSS, but since I want it to start out hidden, that's the only way I can think to do it. What am I doing wrong?Also, I would like a way to show all the hidden texts from one link, and for non javascript browsers to show the texts by default. Link to comment Share on other sites More sharing options...
Pollux Posted February 17, 2006 Share Posted February 17, 2006 The style you have is overriding the style property you are dynamically setting, but you can just put style="display:none" as an attribute for each item and that should work. Or, alternatively you can set the style by a function called onLoad of the body. If you do this, you could keep an array of all the ids which need their style changing. It will then be very simple to write two functions, e.g. collapseAll() and expandAll(). Which just run through all the elements of the array and change the display style to 'none' and 'block' respectively.Call collapseAll() onLoad and expandAll() from your hyperlink. Link to comment Share on other sites More sharing options...
mpoer Posted February 21, 2006 Author Share Posted February 21, 2006 thanks a lot, Pollux. I'll give that a shot on the morning and let you know how it works Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now