Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML/Javascript: Display:none copy and paste issue
    primarykey
    data
    text
    <p>I have read a number of posts on this topic but haven't found a solution to my particular situation. Perhaps there isn't one but I figured I would ask.</p> <p>I have a report being generated in HTML from a powershell script, its being dumped to a folder on a server (NOT A WEBSERVER, so no PHP or any fun stuff available)</p> <p>The report can then be filtered by error type or information. This is done by display:none 'ing various elements, wether they be tr's or div's.. Javascript Below</p> <p>These filters can hide a variety of things making hundreds of possible combinations of different elements possible. So moving them or removing and creating them using DOM's would rough because I dont know how I would tell it where to put the element back. </p> <p>I need to make it so that a filtered report can be copy pasted to send out in emails. Any Ideas?</p> <pre><code> function showhide(button) { if (button.value == 'hide') { var arr = document.getElementsByName(button.name +'tr'); var length = arr.length; for (var i = 0; i &lt; length; i++) { arr[i].style.display = 'none'; } document.getElementById(button.name +'div').innerHTML = "&lt;a href='javascript:void(0)' onclick='showhide(this)' name='" + button.name + "' value='show'&gt;Show " + button.name + "&lt;/a&gt;"; } else if (button.value == 'show') { document.getElementById(button.name +'div').innerHTML = "&lt;a href='javascript:void(0)' onclick='showhide(this)' name='" + button.name + "' value='hide'&gt;Hide " + button.name + "&lt;/a&gt;"; var arr = document.getElementsByName(button.name +'tr'); var length = arr.length; for (var i = 0; i &lt; length; i++) { arr[i].style.display = ''; } } } </code></pre> <p>Solution:</p> <pre><code>function showhide(button) { var seeMe = document.getElementById('visible'); seeMe.innerHTML = ' '; if (button.value == 'hide') { var arr = document.getElementsByName(button.name +'tr'); var length = arr.length; for (var i = 0; i &lt; length; i++) { arr[i].style.display = 'none'; arr[i].name = 'h'; } document.getElementById(button.name +'div').innerHTML = "&lt;a href='javascript:void(0)' onclick='showhide(this)' name='" + button.name + "' value='show'&gt;Show " + button.name + "&lt;/a&gt;"; } else if (button.value == 'show') { document.getElementById(button.name +'div').innerHTML = "&lt;a href='javascript:void(0)' onclick='showhide(this)' name='" + button.name + "' value='hide'&gt;Hide " + button.name + "&lt;/a&gt;"; var arr = document.getElementsByName(button.name +'tr'); var length = arr.length; for (var i = 0; i &lt; length; i++) { arr[i].style.display = ''; arr[i].name = 's'; } } var search = document.getElementById('hidden').children; for(var i = 0; i &lt; search.length; i++) { seeMe.appendChild(search[i].cloneNode(true)); } var paras = document.getElementById('visible').getElementsByTagName('*'); for(var i = 0; i &lt; paras.length; i++) { if (paras[i].name == 'h') { paras[i].parentNode.removeChild(paras[i]); i-- } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload