ifm1989 Posted September 16, 2007 Share Posted September 16, 2007 I want the user to be able to click a link and divs at multiple locations around the page will show/hide. This is my current code echo '<script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == \'block\') e.style.display = \'none\'; else e.style.display = \'block\'; } //--> </script>'; echo "<div id='foo'>sample</div> blah blah <div id='foo'>sample</div>"; echo "<a onclick=\"toggle_visibility('foo');\">Display Details</a>"; The page is PHP (which I know much, much better than Javascript, haha). Any ideas what's up? Is there a way to do this? What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/69550-showhide-multiple-divs/ Share on other sites More sharing options...
ifm1989 Posted September 16, 2007 Author Share Posted September 16, 2007 I've been thinking. This must be caused by multiple divs with the same id. I would be able to generate new names for the divs (foo1, foo2, etc.). So then how would I go about calling my generated list of foo1, foo1, etc? Quote Link to comment https://forums.phpfreaks.com/topic/69550-showhide-multiple-divs/#findComment-349464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.