Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Event Bubbling


Message #1 by "Sowmindra" <rotti.sowmindra@f...> on Wed, 23 Oct 2002 17:35:38 +0530
I just dropped by this thread and took a look at it before dumping it 
to
trashes.  In case you haven't solved your problem, I have a few words 
to
add.

So, you don't want to write all those "onfocus" attributes, right?  In 
this
case, it's not event bubbling that you need, but a function which fills
"onfocus" attributes for you.  If you've read some other posts 
recently,
there's one thread talking about doing so which might give you an idea.
Concretely, it's more or less sthg like this:

use <body ..... onload=3D"filloutOnClicks()"> to call the following 
function:

function filloutOnClicks() {
	for (var i in document.forms) { // get all the forms
		for (var j in document.forms[i].elements) { // get all
elements
			var k =3D document.forms[i].elements[j]
			if (k.tagName =3D=3D whatever_you_want)
				k.onclick =3D whatever_function_you_like
		}
	}
}

Obviously, I just wrote these lines without testing and without really
caring the exact syntax :) but that should give you an idea.

Good luck

> -----Message d'origine-----
> De : Sowmindra [mailto:rotti.sowmindra@f...]
> Envoy=C3=A9 : mercredi 23 octobre 2002 15:12
> =C3=80 : javascript
> Objet : [javascript] Re: SV: Re: SV: Event Bubbling
>
>
> Yeah,
> I got the solution by writing onFocus event in all the text fields
> but i didn't want it that way
> i just want to include one file and it should be handling all
> the focus
> events
> anyway thanks for the reply
> regards
> Sowmindra

  Return to Index