javascript toggle for selected odd and even columns in a table
<p>The Script below is working for either odd or even table columns only. Anybody pl correct/modify to work for both odd and even table columns selected.</p>

<pre><code>var toggle = function (action) {
    var trs = document.getElementById('bar').getElementsByTagName('tr'),
        trs_count = trs.length,
        needed = [],
        total = 0,
        pattern = /\bfoo\b/g,
        initial= 'show';

    for (i=0; i&lt;trs_count; i++) {
        var tds = trs[i].getElementsByTagName('td'),
            tds_count = tds.length;
        for (j=0; j&lt;tds_count; j++) {
            if (pattern.exec(tds[j].className)) {
                needed.push(tds[j]);
                total++;
  } } }
    toggle = function (action) {
        if (this.display == null) {
            this.display = initial;
        }
        if (action == null) {
            this.display = (this.display == 'hide') ? 'show' : 'hide';
        }
        else {
            this.display = action;
        }
        for (i=0; i&lt;total; i++) {
            if (this.display == 'show') {
                needed[i].style.visibility = 'hidden';//changed from display = 'block';
            }
            else {
                needed[i].style.visibility = 'visible';//changed from display = 'none';
            }
        }
        return true;
    }
    return toggle();
}
</code></pre>

<p>Used the following css</p>

<pre><code>.foo{visibility:hidden};
</code></pre>
