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
----- Original Message -----
From: "Robert Nyman" <robert.nyman@c...>
To: "javascript" <javascript@p...>
Sent: Wednesday, October 23, 2002 6:29 PM
Subject: [javascript] SV: Re: SV: Event Bubbling
The problem is that the onFocus event doesn't bubble, i.e. if you
set focus to a FORM element, it won't bubble up to the FORM tag.
Therefore, you need to approach it something like this:
function triggerFocus(){
var oForm = document.getElementById("theForm");
var arrAllInputs = oForm.getElementsByTagName("input");
for(var i=0; i<arrAllInputs.length; i++){
if(arrAllInputs[i].getAttribute("type") == "text"){
arrAllInputs[i].focus(); // Hence the onFocus
event is triggered...
}
}
}
<form id="theForm" name="theForm">
<input type="text" onMouseDown="triggerFocus()"
onFocus="alert(1);">
<input type="text" onMouseDown="triggerFocus()"
onFocus="alert(2);">
<input type="text" onMouseDown="triggerFocus()"
onFocus="alert(3);">
<input type="text" onMouseDown="triggerFocus()"
onFocus="alert(4);">
<input type="text" onMouseDown="triggerFocus()"
onFocus="alert(5);">
</form>
This isn't exactly stabile and it isn't a final solution, just an idea
to get you thinking in the right direction...
/Robert
-----Ursprungligt meddelande-----
Från: Sowmindra [mailto:rotti.sowmindra@f...]
Skickat: den 23 oktober 2002 14:36
Till: javascript
Ämne: [javascript] Re: SV: Event Bubbling
Hi Robert,
Where do we invoke the function triggerFocus()?
For the form tag,the attribute onFocus doesn't exist
event if i write in the script as
document.onfocus = triggerFocus;
its not working
Regards
Sowmindra
----- Original Message -----
From: "Robert Nyman" <robert.nyman@c...>
To: "javascript" <javascript@p...>
Sent: Wednesday, October 23, 2002 5:49 PM
Subject: [javascript] SV: Event Bubbling
eventBubbling bubbles up in the HTML structure.
For example:
<form onClick="alert('This is the form')">
<input type="text" onClick="alert('This is the input field')"> </form>
This will result in that the onClick event on the INPUT field is
triggered first, then the onClick event on the FORM. Since you can't
nest INPUT fields, this is not a way to do it.
But if you want to trigger the onFocus event on every INPUT field, try
this:
function triggerFocus(){
var oForm = document.getElementById("theForm");
var arrAllInputs = oForm.getElementsByTagName("input");
for(var i=0; i<arrAllInputs.length; i++){
if(arrAllInputs[i].getAttribute("type") == "text"){
arrAllInputs[i].focus(); // Hence the onFocus event is triggered... } }
}
/Robert
-----Ursprungligt meddelande-----
Från: Sowmindra [mailto:rotti.sowmindra@f...]
Skickat: den 23 oktober 2002 14:06
Till: javascript
Ämne: [javascript] Event Bubbling
Hi All,
I need a script that automatically captures all the onfocus events on
all the input fields in a form. I heard that eventBubbling can be used.
Can anyone tell me how can we achieve this. Thanks and Regards Sowmindra
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20