Hello, I found a script for innerHTML, which has a basic expand / collapse function. However, when it comes to table cells … it craps out. I know some form of toggle function needs to be added, something the lines of this
However, I cannot make the two codes cohere. Here is the innerHTML script
I've tried quite a bit to make them work, however, I cannot make it work. Is it possible to add the toggle table cell function to the innerHTML, or vice-versa
Code:
function toggle(id) { var tr = document.getElementById(id);
if (tr==null) { return; } var bExpand = tr.style.display == '';
tr.style.display = (bExpand ? 'none' : ''); }
function Toggle_h1() { toggle('row1'); toggle('row2'); }
function Toggle_h2() { toggle('row3'); toggle('row4'); }
Code:
function toggle(eina,id,show,hide) {
var tvo = document.getElementById( id );
if( eina.innerHTML == hide ) { eina.innerHTML = show;
tvo.style.display = 'none'; } else { eina.innerHTML = hide;
tvo.style.display = 'block'; } }
Comment