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:
- <script type="text/javascript">
- var rowVisible = true;
- function toggleDisplay(tbl) {
- var tblRows = tbl.rows;
- for (i = 0; i < tblRows.length; i++) {
- if (tblRows[i].className != "headerRow") {
- tblRows[i].style.display = (rowVisible) ? "none" : "";
- }
- }
- rowVisible = !rowVisible;
- }
- </script>
- <table id="theTable" align="center">
- <tr class="headerRow">
- <th class="title1" width="700"></th>
- <tr>
- <td class=window2>
- <!-- BEGIN CBOX - www.cbox.ws - v001 -->
- <div id="cboxdiv" style="text-align: center; line-height: 0">
- <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>
- <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>
- </div>
- <!-- END CBOX -->
- </td>
- </tr>
- </table>
- <input type="button" value="Open/Close cBox" onclick="toggleDisplay(document.getElementById('theTable'))" />
- </center>
Edit: Also if someone could clean it up as well. I'm a messy coder![]()
Thank you![]()
edit 2: Just realized I put this in the wrong place..![]()
Bump?
For it to remain hidden, you'll have to look into the usage of 'cookies' and store the hidden status of each table!![]()
Would this be it?
Code:
- function Set_Cookie( name, value, expires, path, domain, secure )
- {
- // set time in milliseconds
- var today = new Date();
- today.setTime( today.getTime() );
- if ( expires )
- {
- expires = expires * 1000 * 60 * 60 * 24;
- }
- var expires_date = new Date( today.getTime() + (expires) );
- document.cookie = name + "=" +escape( value ) +
- ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
- ( ( path ) ? ";path=" + path : "" ) +
- ( ( domain ) ? ";domain=" + domain : "" ) +
- ( ( secure ) ? ";secure" : "" );
- }
I'm a bit rusty with my coding, I have not coded in like 3 months.
Where did you get that from?
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.![]()
What is the correct way to do it?