This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to get Events associated with DOM elements ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to get Events associated with DOM elements ?" Watch "How to get Events associated with DOM elements ?" New topic
Author

How to get Events associated with DOM elements ?

Mohit J Kumar
Greenhorn

Joined: Apr 08, 2010
Posts: 28

Hi everyone,

I have an HTML document.
It is possible to get the events associated with every Element in a particular FORM element in the document using javascript.

var element = document.forms[i].elements[j];

This way I can get j th element in i th form, But can I get the event associated with the element.
There can be any number of elements in a form.I am using IE 8.

I am a total beginner in javascript/javascript event handling.


Thanks

"It's good to B in touch...So keep responding"
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
"get the events associated"

What do you mean by events?

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Events aren't associated with elements until they are triggered. You'll need to explain what you are after in much better detail.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mohit J Kumar
Greenhorn

Joined: Apr 08, 2010
Posts: 28


Actually I was trying to serialize HTML DOM into XML.

what I did to do this was :



What I am getting from this is an XML :




Now Suppose I have :

<input tabindex="7" name="button" type="button" class="button"
style="width:100;height:30" Value="Continue" onclick='login()' />

All I want to do now is to get onClick in my XML or any event associated like onBlur() etc.


Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are writing XML why?

Eric
Mohit J Kumar
Greenhorn

Joined: Apr 08, 2010
Posts: 28

Well I don't want to mess with my javascript code every time I need to change/manipulate my DOM.
I am planning to create a tool which will create an HTML DOM out of this XML file.
So here I will do it in three steps.

Step 1 : Get HTML DOM (which I need to manipulate) serialized to well formatted XML file.
Step 2 : Make changes in XML.
Step 3 : Use the XML to reflect the changes in the HTML DOM.

<input tabindex="7" name="button" type="button" class="button"
style="width:100;height:30" Value="Continue" onclick='login()' />

Now in Step1 I am not able to get onclick='login()' information in my XML.
There may be other events like this e.g, onBlur, onFocus etc.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to get Events associated with DOM elements ?
 
Similar Threads
Trace status change of DOM elements
getting id attribute value of html element
how to get POST Variables of a page using javascript
using SAX and building xml on-the-fly
Getting elements in td