[thelist] Javascript: altering BG color of multiple divs with one click

Dunstan Orchard dunstan at 1976design.com
Wed Nov 12 04:23:02 CST 2003


Thanks for all the comments on this guys.

Marcus <marcan at home.se> said "I really don't know why you would want to do this,
but okay..."

Well, the reason I wanted to do it was to add some functionality to a blog
comments system I was making. If you're interested you can see it explained here:

http://www.1976design.com/blog/archive/2003/11/12/48/

Though it's certainly had some holes shot in it, I'm still pleased with the
result. And I couldn't have done it without your help, so danke.


> From: "James Aylard" <evolt at pixelwright.com> wrote:
> 
> One coding practice that can help alleviate this problem to some degree
> is to place the numeric value as the left operand and the variable as the
> right operand, e.g.:
> 
> if (0 == i)
> 
> Because if you goof it up and only type one "equal" sign, e.g.:
> 
> if (0 = i)
> 
> it will throw a Javascript error.

Ah yes, good point, I saw that written down for PHP the other day, I must
remember it. Thanks.


Cheerio - Dunstan

p.s. If you ever find yourself building a system that uses Javascript's onclick,
and you change that behaviour to ondblclick for testing purposes, be sure not to
go for lunch and forget what you did. You could spend two hours frantically
stripping everything from your code trying to find out why the system no longer
works when you 'click' :o)

---------------------------
Dorset, England
http://www.1976design.com/
http://www.1976design.com/blog/


More information about the thelist mailing list