HighCaliber Posted August 14, 2006 Share Posted August 14, 2006 I am trying to create a toggle function for my forum.Here is my javasript code... <script type="JavaScript">function toggle(obj1, obj2) { var el = document.getElementById(obj1); var el2 = document.getElementById(obj2); if ( el.style.display != 'none' ) { el.style.display = 'none'; el2.src = "Themes/Default/Images/category_expand.png"; } else { el.style.display = ''; el2.src = "Themes/Default/Images/category_shrink.png"; }}</script> and here is what i am trying to toggle... <a href="java script:toggle(1, si1)"><img alt="" border="0" src="Themes/Default/Images/category_shrink.png" id="si1" /></a><table cellspacing="1" class="Section_Middle" id="1"><tr><td>content to toggle</td></tr></table> For some reason this will not work, when i go to validate it it says el2 has no properties. Can anyone figure how to fix this or show me a valid (W3C Standards) way to toggle two objects. Link to comment Share on other sites More sharing options...
aspnetguy Posted August 14, 2006 Share Posted August 14, 2006 your problem is here <a href="java script:toggle(1, si1)"> change it to this <a href="java script:toggle('1', 'si1')"> hmm it keeps putting a space between java and script, just take that out in your code. Link to comment Share on other sites More sharing options...
HighCaliber Posted August 14, 2006 Author Share Posted August 14, 2006 Thank you, it finally works i have been asking around on multiple forums trying to get this fixed and it was so simple. Now I feel stupid lol 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