CODE
<html>
<head>
</head>
<body>
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
function tableIsVisible(){ return readCookie("showtable")=="true"; }
function toggleCookie(){ if(readCookie("showtable") == "false") createCookie("showtable","true",365*60*24*10); else createCookie("showtable","false",65*60*24*10); }
function displayRow(show){
var row = document.getElementById("captionRow");
if (show=="false") row.style.display = 'none';
else row.style.display = '';
}
displayRow(tableIsVisible());
</script>
<table width="300" border="1" id="captionRow">
<tr><th>TH-1</th><th>TH-2</th><th>TH-3</th></tr>
<tr><td>cell-11</td><td>cell-12</td><td>cell-13</td></tr>
<tr><td>cell-21</td><td>cell-22</td><td>cell-23</td></tr>
</table>
<p><button onclick="toggleCookie(); displayRow(tableIsVisible());" >Show / Hide</button></p>
</body>
</html>
<head>
</head>
<body>
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
function tableIsVisible(){ return readCookie("showtable")=="true"; }
function toggleCookie(){ if(readCookie("showtable") == "false") createCookie("showtable","true",365*60*24*10); else createCookie("showtable","false",65*60*24*10); }
function displayRow(show){
var row = document.getElementById("captionRow");
if (show=="false") row.style.display = 'none';
else row.style.display = '';
}
displayRow(tableIsVisible());
</script>
<table width="300" border="1" id="captionRow">
<tr><th>TH-1</th><th>TH-2</th><th>TH-3</th></tr>
<tr><td>cell-11</td><td>cell-12</td><td>cell-13</td></tr>
<tr><td>cell-21</td><td>cell-22</td><td>cell-23</td></tr>
</table>
<p><button onclick="toggleCookie(); displayRow(tableIsVisible());" >Show / Hide</button></p>
</body>
</html>