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
---
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