knowram Posted June 15, 2007 Share Posted June 15, 2007 found this cool little peace of code to show and hide things. <html> <head> <title>test</title> <script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'none') e.style.display = 'block'; else e.style.display = 'none'; } //--> </script> </head> <BODY> <input type="checkbox" name="Sort_Office" value="yes" onclick="toggle_visibility('foo');" /> <div id="foo">This is foo</div> <br> <a href="#" onclick="toggle_visibility('foo2');">Click here to toggle visibility of element #foo</a> <div id="foo2">This is foo2</div> </body> </html> right now when you lode the page it is showing the info. I would like it to be the other way around. and someone help. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/55658-show-hide/ Share on other sites More sharing options...
nogray Posted June 15, 2007 Share Posted June 15, 2007 just add style="display:none;" to the div tags Quote Link to comment https://forums.phpfreaks.com/topic/55658-show-hide/#findComment-275036 Share on other sites More sharing options...
knowram Posted June 15, 2007 Author Share Posted June 15, 2007 thank worked like a charm. Quote Link to comment https://forums.phpfreaks.com/topic/55658-show-hide/#findComment-275097 Share on other sites More sharing options...
jimmyyami Posted June 15, 2007 Share Posted June 15, 2007 <html> <head> <title>test</title> <script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'none') e.style.display = 'block'; else e.style.display = 'none'; } //--> </script> <style type="text/css"> <!-- #foo{ display:none; } --> </style> </head> <BODY> <input type="checkbox" name="Sort_Office" value="yes" onclick="toggle_visibility('foo');" /> <div id="foo">This is foo</div> <a href="#" onclick="toggle_visibility('foo2');">Click here to toggle visibility of element #foo[/url] <div id="foo2">This is foo2</div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55658-show-hide/#findComment-275337 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.