File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Attach eventListener to objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Attach eventListener to objects" Watch "Attach eventListener to objects" New topic
Author

Attach eventListener to objects

R Naijat
Ranch Hand

Joined: Nov 01, 2011
Posts: 40
Hi everybody,
I have this piece of code which calls the charCounter() function anytime user enters any letter in the input. Its working properly:




Now I am trying to mimc the above code, sending the title and left objects instead:

I have defined the following objects:



I think 'a' and 'b' are correct objects b/c a.value and b.value are the correct values, so I send the 'a' and 'b' objects to charCounter() function and expect the charCounter() function gets called anytime user
enters any letter in the Title or Left fields. Following is how I tried to attach the even listeners to the objects, also call the function.



How can I fix this?
R Naijat
Ranch Hand

Joined: Nov 01, 2011
Posts: 40
Some correction to the code! I modified the code as following; when the script executes for the first time, it gets inside charCounter() function and does calculate the remaining chars correctly, b/c I get:

TITLE: Auto Body and Paint
16 characters left

But then it does not do anything else as I type in Title field. So can you help me fix this in a way that does NOT go inside charCounter() when the script executes for the first time and instead gets in that function when user enters anything in the field?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Attach eventListener to objects
 
Similar Threads
Calling a JavaScript function from within another JavaScript function
Uncaught TypeError: Cannot read property 'length' of undefined
Question on jQuery ajax functionality & troubleshooting called bean in JSF page
Need Help With Dynamic text box in JSP
"Unterminated <c:out tag" Error