Sorry for the previous post ...

So, I would like to show/hide some <td>. I fisrt verify if checkbox
are checked on form load.  And then, I use a function for each
checkbox. I have 5 of them to verify, so 5 calls to myToggleDisplay
which just this part took 9 sec more under IE6 (only for these
checkbox) !

Here is my function with some modification. I have also moved the
changeBg() function.

function myToggleDisplay(checkbox, targets){
        var targets = $(targets);
        var checkbox = $(checkbox);

        //check the checkbox when the edit form is loaded
        if (checkbox.checked) {
                targets.show();
        }

        checkbox.click( function() {
          if (this.checked) {
                targets.show();
           } else {
                targets.hide();
           }
        }).triggerHandler('click');
}


myToggleDisplay('input#myCheckboxID', 'td.areaToShow');
.
.
.

I'm begin to be crazy with this, any help will be very much
appreciated.

Damien


On Nov 14, 10:30 pm, Flesler <[EMAIL PROTECTED]> wrote:
> Can you make a model of your situation ? that could help.
> What do you want to do exactly? to show/hide many tds when a checkbox
> is clicked? and changeBg(), that's for creating a zebra-like striping
> of the cells ?
> First of all, if you want to show ALL the cells in a table, or a row,
> you can just toggle the table or the row. That's surely faster. Maybe
> this helps...
>
> function myToggleShow( checkbox, targets ){
>   targets = $(targets);
>   $(checkbox).click( function() {
>      if ( this.checked ){
>         targets.show('slow');
>         changeBg(); //is really neccesary to call this EVERY time you
> click the checkbox?
>      } else {
>          targets.hide('slow');
>      }
>   }).triggerHandler('click');
>
> }
>
> myToggleDisplay('#myCheckboxID', 'td.areaToShow');
>
> Ariel Flesler
>
> On 14 nov, 13:54, Snook <[EMAIL PROTECTED]> wrote:
>
> > Dear developers,
>
> > I have a function which is called several times, when my page is
> > loaded. This is VERY slow under IE, because I have a lot of checkbox.
>
> > Did someone can explain me this difference between FF and IE ? And
> > maybe how to improve this function :
>
> > function myToggleShow(checkboxElem, showHideElem){
> >   var showHide = $(showHideElem);
> >   var checkbox = $(checkboxElem);
> >   checkbox.click( function() {
> >     if (checkbox.is(":checked")) {
> >       showHide.show('slow');
>
> >       // Change the background for "even" lignes
> >       changeBg()
> >     } else {
> >         showHide.hide('slow');
> >     }
> >   });
>
> >   // check the checkbox status when the form is loaded
> >   if (checkbox.is(":checked")) {
> >         showHide.show('slow');
> >   }
>
> > }
>
> > myToggleDisplay('#myCheckboxID', 'td.areaToShow');
>
> > FYI, I cannot use the toggle function, which didn't work with
> > checkbox !!!
>
> > Thanks,
>
> > Damien

Reply via email to