Hey Scott,

No offense, and not particularly helpful in this case, but *why on earth*
would you want to do something like that in JavaScript???

Any sort of thing like that, with large loops, and modified output based on
data that (I hope) is stored in a database is *definitely* better handled
server-side using something like PHP, or if you're into that sort of thing;
Cold Fusion or ASP.

Is there a particular reason why you want it done in JS? (Mind you - I am very
impressed at your code and having it work!)

Cheers,

Beau

-- 
Beau Lebens
Information Architect
[EMAIL PROTECTED]
Dented Reality - www.dentedreality.com.au
Information Architecture, Usability, Web Development

scott parsons said:
>
> OK, so a different standard from the one we usually talk about
> I have this page
> http://positionrelative.com/snippets/jstest.htm
>
> Now if you visit the site you should see a huge list of suburbs, to
> which I am adding some letter headers for each letter. Sounds simple
> enough except that it takes far too long for the JS to work, and I'm
> stuck as to how to improve it.
> My js function is
>
> function recurseNodes(aNodes) {
>     for (var i=0; i<aNodes.length; i++) {
>         if (aNodes[i].nodeType == 1) {
>             if (aNodes[i].tagName.toLowerCase() == "label") {
>                 //label found
>                 //get first character
>                 var c = aNodes[i].innerHTML.charAt(0);
>                 if (c != currentLetter) {
>                     //insert node for for new letter heading
>                     var newNode = document.createElement("h2");
>                     newNode.innerHTML = c.toUpperCase();
>
> aNodes[i].parentNode.parentNode.insertBefore(newNode, aNodes[i].parentNode);
>
>                     //for safari
>                     //var newNode2 = document.createElement("a");
>                     //newNode2.setAttribute("name", sPrefix +
> c.toLowerCase());
>
> //aNodes[i].parentNode.parentNode.insertBefore(newNode,
> aNodes[i].parentNode);
>
>                     //set current letter
>                     currentLetter = c;
>                 }
>             }
>             //recurse
>             if (aNodes[i].hasChildNodes) {
>                 recurseNodes(aNodes[i].childNodes);
>             }
>         }
>     }
> }
>
>
> The safari bit was for another additional function which has now been
> curtailed (I have very much the moving goalposts on this one!)
> If anyone could think of a better way to do this, or even an efficiency
> tweak I would be very grateful.
>
> p.s. this page is just a snippet so may be a little messy...apologies
>
>
> thanks
>
> scottbp
> *****************************************************
> The discussion list for http://webstandardsgroup.org/
> *****************************************************
>
>

*****************************************************
The discussion list for http://webstandardsgroup.org/
***************************************************** 

Reply via email to