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> Link to comment https://forums.phpfreaks.com/topic/199242-adding-a-plus-and-minus-to-openclose/ 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'; } } Link to comment https://forums.phpfreaks.com/topic/199242-adding-a-plus-and-minus-to-openclose/#findComment-1045698 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! Link to comment https://forums.phpfreaks.com/topic/199242-adding-a-plus-and-minus-to-openclose/#findComment-1045703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.