[thelist] JavaScript: style.display

Matt Warden mwarden at gmail.com
Wed Nov 30 03:02:49 CST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Casey wrote:
> P.S. The app is classic ASP, but I think that won't matter as this is all a 
> clientside issue.

Well, that's part of your problem. A fully client-side solution probably
isn't best. However, you could do this fully client-side by saving the
state in cookies. Maybe a series of bits (or the hexidecimal
representation if you're worried about the cookie filesize limitation).

e.g.:

tableState=0000000000010010000001010000000000000100000000100100010100000001

Then you would reconstruct the state onload setting all tr's to
display='none' where its respective bit is 0 and display='' where its
respective bit is 1.

Something like (pardon me if I intermingle JavaScript and Java syntax --
but this is the general idea):

// where mycookie is a string with the value of tableState cookie above
var trs = document.getElementById('mytable').getElementsByTagName('tr');
for (var i=0; i<trs.length; i++) {
    if (mycookie.charAt(i)=='0') {
        trs[i].style.display = 'none';
    }
    else {
        trs[i].style.display = '';
    }
}


- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDjWq5rI3LObhzHRMRApwtAKDGrITMlEoFDRfSP20h2G+Y6C/efgCcCGpJ
qwHaOuCroevNoaRADVnFfjE=
=4wbi
-----END PGP SIGNATURE-----



More information about the thelist mailing list