wispas Posted April 21, 2010 Share Posted April 21, 2010 i have a script that expands and collapses a div tag when the a:link has been clicked. i have added an extra div at the bottom called status and wanted it to display some words as to whether the box is expanded or collapsed; can anyone help me with this... im guessing its adding some code into the javascript that i already have. <html> <head> <title>Show/Hide Element</title> <script type="text/javascript"> function showHide(div){ if(document.getElementById(div).style.display == 'none'){ document.getElementById(div).style.display = 'block'; }else{ document.getElementById(div).style.display = 'none'; } } </script> </head> <body> <a href="#"><div id="filter" onClick="showHide('filtersearch');">Filter Search Results</div></a> <div id="filtersearch" style="display:none;">Put content here</div> <div id="status"></div> </body> </html> Quote Link to comment Share on other sites More sharing options...
grim1208 Posted April 21, 2010 Share Posted April 21, 2010 edit your javascript function to look something like this. function showHide(div) { if(document.getElementById(div).style.display == 'none') { document.getElementById(div).style.display = 'block'; document.getElementById('status').innerHTML = 'open'; } else { document.getElementById(div).style.display = 'none'; document.getElementById('status').innerHTML = 'close'; } } Quote Link to comment Share on other sites More sharing options...
wispas Posted April 21, 2010 Author Share Posted April 21, 2010 that worked so well... exactly what i was looking for... thank you very much! Quote Link to comment 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.