Hiding / Showing a Table with JavaScript -


hi have atable data , have expand , collapse button there if click on + expand , show table , if click on-it collapse , using following code getting error

document.getelementbyid('elename');  imagexchk='expand';   loadedcheck='false'; function toggledisplaycheck(e, tablesize){  element = document.getelementbyid(e).style;  if (element.display=='none') {     element.display='block';     }  else {     element.display='none';     }   if (loadedcheck=='false') {     myupdater('returnsdetailstable', '/oasis/faces/merchant/dashboard/returnsdetailscheck.jsp', { method: 'get' });      loadedcheck='true'     }      size = tablesize-1;     elename = 'mercperfdashboardform:returnsdetailstable:' + size +':switchimageretchk'  if (imagexchk=='collapse') {     document.getelementbyid('elename').src='${pagecontext.request.contextpath}/images/expand.gif';imagexchk='expand';     }   else {     document.getelementbyid('elename').src='${pagecontext.request.contextpath}/images/collapse.gif';imagexchk='collapse';     }        return false; } 

if element's style's display property hasn't been explicitly set in javascript, empty, if element hidden via css rule. easiest thing know initial state (hidden or visible) , assume state if display property empty:

if (element.display=='none' || element.display=='') {     element.display='block';     }  else {     element.display='none';     } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -