Jump to content

[SOLVED] JS help


darkfreaks

Recommended Posts

i need help hiding and matching tables. maybe i am doing it wrong since it dont work ???

 

t= document.getElementsByTagNames();
if(t.match("</table>") { display: none!important; }
if(t.match("<table>") { display: none!important; }	
if(t.match("table") { display: none!important; }

Link to comment
https://forums.phpfreaks.com/topic/155109-solved-js-help/
Share on other sites

This code works, but it's not 100%.  For some reason it has to be clicked twice the first time (which is unacceptable), but it will point you in the right direction.

 

<script type="text/javascript">
function toggle()
{
  var tables = document.getElementsByTagName('table');
  
  for(var i = 0; i < tables.length; i++)
  {
    var x = tables[i];
      x.style.display = (x.style.display == "block") ?
        x.style.display = "none" : x.style.display = "block";
  }
}
</script>

Link to comment
https://forums.phpfreaks.com/topic/155109-solved-js-help/#findComment-816118
Share on other sites

I've always checked for display:none, and assumed anything else is visible.

<script type="text/javascript">
function toggle()
{
  var tables = document.getElementsByTagName('table');

  for(var i = 0; i < tables.length; i++)
  {
    var x = tables[i];
      x.style.display = (x.style.display == "none") ?
        x.style.display = "block" : x.style.display = "none";
  }
}
</script>

Link to comment
https://forums.phpfreaks.com/topic/155109-solved-js-help/#findComment-816165
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.