mikejs Posted January 15, 2010 Share Posted January 15, 2010 Hi is it possible to use java to close a div on this button click <a class="button" id="submitbutton" href="#"><span id="buttontext">Search</span> </a> I did try using onclick="changeme('notice', 'hide');" notice being the name of the div with <script> function changeme(notice, action) { if (action=="hide") { document.getElementById(notice).style.display = "none"; } else { document.getElementById(notice).style.display = "block"; } } </script> in my header but it didn't work any suggestions :-) Link to comment https://forums.phpfreaks.com/topic/188599-is-it-possible-to-hide-a-div-on-button-click/ Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 It sure is.. but its not done with PHP.. Wrong forum.. <a href="javascript:checkit('id')">Toggle View</a> <div id="id">Some pretty stuff in here</div> thats your html <script type="text/javascript"> function checkit(var) { document.getElementById(var).style.display = (document.getElementById(var).style.display == 'none' ? 'block' : 'none'); } </script> Link to comment https://forums.phpfreaks.com/topic/188599-is-it-possible-to-hide-a-div-on-button-click/#findComment-995703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.