Forum Moderators: open
window.onload = function()
{
var hideClasses = {class1:1,class2:1} var allCells = document.getElementById("tableID").getElementsByTagName("td")
for(var k=0;k<allCells.length;k++)
{
var cell = allCells[k]
if(hideClasses[cell.className])
cell.style.display = "none"
}
}
STYLE METHOD (better)
Script block in the BODY:
<script>
var hideClasses = ["class1","class2"]
if(notAuthorisedCondition)
{
document.write("<style>")
for(var k=0;k<hideClasses.length;k++)
document.write("."+hideClasses[k]+"{display:none;}")
document.write("<\/style>")
}
</script>
..that's if you're doing this on the client side.
If you're doing it on the server, why not just not serve them the columns in the first place? Whether displayed or not, the cells will still be visible in the page code if served.
Have I missed something?
Perhaps a bigger issue is accommodating archaic DOM's if one chooses to use DHTML to change CSS attributes.
As for straight questions, remember the wisdom of Snidely Wiplash, "It's hard to think straight with a crooked mind."