Re: (simple?) DOM problem
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: (simple?) DOM problem

From: bmgz <bmg2x@yahoo.com>
Date: Wed Feb 08 2006 - 18:27:53 CET

I tried to simplify the the code, but I ended up making a hash of things,
It is DHTML because I brought CSS into the mix (not visible in my pityful earlier post)
I can code but my jargon sux like **** (I don't converse verbally with other coders..)
anyways here goes:

function viewPhoto(thumb){
        document.getElementById('mainPhoto').src=thumb.href;
        thumbs = document.getElementById('property-thumbnail-browser').getElementsByTagName('img');
        for(i=0; i<thumbs.length; i++){
                thumbs[i].className="thumbnail-normal";
        }
        thumb.firstChild.className="thumbnail-current";
        return false;
}

I want to neaten this code by changing the loop logic to:

function viewPhoto(thumb){
        document.getElementById('mainPhoto').src=thumb.href;
        thumbs = document.getElementById('property-thumbnail-browser').getElementsByTagName('img');
        for(i=0; i<thumbs.length; i++){
                < If this is the image i clicked on > <-- I need to find the Index of the object???
                        thumb.firstChild.className="thumbnail-current";
                < Else >
                        thumbs[i].className="thumbnail-normal";
        }
        
        return false;
}

I know this looks crude because the firstChild etc. relies implicitly on my markup being precise,
but it works for me... Another wierd thing I noticed was Firefox treating a literal space ' ' in
your markup as a Node?
Received on Mon May 1 03:10:31 2006