showing or hiding div with id generated using php and javascript -


i trying hide or show div based on div id php function. not able make work, please me.

javascript:

<script> showorhide(id) {     var elem=getelementbyid(id);     if(elem.style.visibility="hidden")         elem.style.visibility="visible";     else         elem.style.visibility="hidden"; } </script> 

php script:

<?php function display_link($link_id,$upvote_array,$downvote_array,$divid) { ?>     <a href="javascript:showorhide(<?php echo $divid; ?>)">more links</a>     <div id="<?php echo $divid ?>" style="visibility:hidden;">     </div> <?php } ?> 

here's cleaned-up version of function.

function showorhide(id) {    var elem = document.getelementbyid(id);    elem.style.visibility = (elem.style.visibility === 'hidden')? 'visible' : 'hidden'; } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -