Jump to content

Show/Hide Multiple Divs


ifm1989

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/69550-showhide-multiple-divs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.