Jump to content

Toggle Function


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...