By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

How would I add innerHTML to my expandable content script?

P: 1
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

Expand|Select|Wrap|Line Numbers
  1. function toggle(id) { var tr = document.getElementById(id);
  2. if (tr==null) { return; } var bExpand =  tr.style.display == '';
  3. tr.style.display = (bExpand ? 'none' : ''); }
  4. function Toggle_h1() { toggle('row1'); toggle('row2'); }
  5. function Toggle_h2() { toggle('row3'); toggle('row4'); }
  6.  
However, I cannot make the two codes cohere. Here is the innerHTML script

Expand|Select|Wrap|Line Numbers
  1. function toggle(eina,id,show,hide) {
  2. var tvo = document.getElementById( id );
  3. if( eina.innerHTML == hide ) { eina.innerHTML = show;
  4. tvo.style.display = 'none'; } else { eina.innerHTML = hide;
  5. tvo.style.display = 'block'; } }
  6.  
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
Nov 29 '09 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
the CSS property display (line #2) must have a value ('' is invalid). (I think it has to be "table-row")
Nov 29 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.