Title: getElementsByClassName

How should I expect the performance of this function to be?

I wrote this code:

function CreateTOC(){
                       
        var $aTOC = document.getElementsByClassName('tocitem');

        if(isArray($aTOC)){
       
                $temp = '<INPUT TYPE="SUBMIT" NAME="cmdSave_Update" VALUE="Close" CLASS="menubuttons"> ';
                $temp += '<INPUT TYPE="SUBMIT" NAME="cmdSave_Update" VALUE="Save_Update" CLASS="menubuttons"> ';
                $temp += '<SELECT NAME="cboTOC" ';
                $temp += '<OPTION VALUE="">Table of Contents</OPTION>';

                for($i = 0; $i < $aTOC.length; $i ++){
                       
                        $sValue         = $aTOC[$i].name;
                        $sName  = $aTOC[$i].innerHTML;
                        $temp   += '<OPTION VALUE="' + $sValue + '">' + $sName+ '</OPTION>';
                        alert($sValue);
                        }
               
                $temp += '</SELECT> ';
                $temp += '<INPUT TYPE="SUBMIT" NAME="cmdOpenReport" VALUE="Open Report" CLASS="menubuttons"> ';
                <?php if($_SESSION['PrintOptions'] == 0) $sPrintOptions = 'Off'; else $sPrintOptions = 'On';?>
                $temp += '<INPUT TYPE="SUBMIT" NAME="cmdPrintOptions"  VALUE="Print Options <?=$sPrintOptions?>" ';
                $temp += 'STYLE="font-size: 9px; width: 90px" CLASS="menubuttons"> ';
                $('menu').innerHTML = $temp;
                       
                }

        }

In a small page (258 lines of code), it's quick, in another page (7500 lines of code), it takes 10-15 seconds to load. I've checked and most of the delay is getElementsByClassName.

Is that right?

_____________________
Thanks,  

Keith Davis - MCSA, A+, N+
P.R.I.D.E. - Director of Computer Services
www.pridedallas.com
Work (214) 351-6600 ext. 119
Mobile (214) 906-5183


_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to