vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: Expand/collapse Table help - ASAP - View Topic
Topic Rating: *****
Printable View
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Expand/collapse Table help - ASAP (20th Mar 09 at 4:32am UTC)
Moved it to the correct place.
So I am trying to make an expand/collapse tables, I got it to work so far, but it wont stay collapsed when the page is refreshed.
http://fd.vforums.co.uk/

Code:
 
  1. <script type="text/javascript">
  2.  
  3. var rowVisible = true;
  4.  
  5. function toggleDisplay(tbl) {
  6.    var tblRows = tbl.rows;
  7.    for (i = 0; i < tblRows.length; i++) {
  8.       if (tblRows[i].className != "headerRow") {
  9.          tblRows[i].style.display = (rowVisible) ? "none" : "";
  10.       }
  11.    }
  12.    rowVisible = !rowVisible;
  13. }
  14.  
  15. </script>
  16.  
  17. <table id="theTable"  align="center">
  18.    <tr class="headerRow">
  19.      <th class="title1" width="700"></th>
  20.      <tr>
  21.         <td class=window2>
  22. <!-- BEGIN CBOX - www.cbox.ws - v001 -->
  23. <div id="cboxdiv" style="text-align: center; line-height: 0">
  24. <div><iframe frameborder="0" width="780" height="175" src="http://www5.cbox.ws/box/?boxid=367125&boxtag=7891&sec=main" marginheight="2" marginwidth="2" scrolling="auto" allowtransparency="yes" name="cboxmain" style="border:#FFFFFF 1px solid;" id="cboxmain"></iframe></div>
  25. <div><iframe frameborder="0" width="780" height="75" src="http://www5.cbox.ws/box/?boxid=367125&boxtag=7891&sec=form" marginheight="2" marginwidth="2" scrolling="no" allowtransparency="yes" name="cboxform" style="border:#FFFFFF 1px solid;border-top:0px" id="cboxform"></iframe></div>
  26. </div>
  27. <!-- END CBOX -->
  28.      </td>
  29.    </tr>
  30. </table>
  31.  
  32. <input type="button" value="Open/Close cBox" onclick="toggleDisplay(document.getElementById('theTable'))" />
  33. </center>
  34.  
 


Edit: Also if someone could clean it up as well. I'm a messy coder {Tongue Out}

Thank you {Smile}

edit 2: Just realized I put this in the wrong place.. {Unsure}
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Expand/collapse Table help - ASAP (23rd Mar 09 at 6:37pm UTC)
Bump?
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Expand/collapse Table help - ASAP (24th Mar 09 at 10:28am UTC)
For it to remain hidden, you'll have to look into the usage of 'cookies' and store the hidden status of each table! {Smile}
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Expand/collapse Table help - ASAP (24th Mar 09 at 7:10pm UTC)
Would this be it?

Code:
 
  1. function Set_Cookie( name, value, expires, path, domain, secure )
  2. {
  3. // set time in milliseconds
  4. var today = new Date();
  5. today.setTime( today.getTime() );
  6.  
  7. if ( expires )
  8. {
  9. expires = expires * 1000 * 60 * 60 * 24;
  10. }
  11. var expires_date = new Date( today.getTime() + (expires) );
  12.  
  13. document.cookie = name + "=" +escape( value ) +
  14. ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  15. ( ( path ) ? ";path=" + path : "" ) +
  16. ( ( domain ) ? ";domain=" + domain : "" ) +
  17. ( ( secure ) ? ";secure" : "" );
  18. }
  19.  
 


I'm a bit rusty with my coding, I have not coded in like 3 months.
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Expand/collapse Table help - ASAP (25th Mar 09 at 12:30pm UTC)
Where did you get that from?
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Expand/collapse Table help - ASAP (26th Mar 09 at 2:47am UTC)
I actually have no clue, it was on my friends computer, and I asked if I could have the coding he has, and he said sure. Though he is more of a newb then me though. {Tongue Out}

What is the correct way to do it?
 Printable View

All times are GMT+0 :: The current time is 8:51am
Page generated in 0.2423 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums