Hi I was wondering if someone could help me code this so that this table stays the width chosen on refresh.
Thanks so much!
HTML Code:<html> <head> <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 switchheight() { var orig='500'; var el=document.getElementById('width'); el.width=(el.width==='500')?'200':'500'; } </script> </head> <body> <table class="orig" id="width"> <tr> <td bgcolor="green">demo table</td> </tr> </table> <input type="button" value="width" onclick="switchheight();Cookie.setCookie('tableClass','class');"> <script type="text/javascript"> window.onload=function () { var lngt = document.getElementsById('class'); if(readCookie('width')) { lngt[0].el.width=readCookie('width'); } }; </script> </body> </html>



Reply With Quote

Bookmarks