Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  76] [ 5]  / answers: 1 / hits: 20892  / 15 Years ago, fri, january 15, 2010, 12:00:00

I have a JavaScript library that updates a hidden <textarea> HTML element with some data based on some things.



In my (JavaScript) application I'd like to know when these updates occur without having to go through the existing library code.



I was hoping there was an event for this, but apparently not.



How would I listen for changes of the textarea?



Changes can be as simple as document.getElementById(myTextarea).value = hello;



EDIT I will be using FireFox only, since this code will only be part of a test suite I'm building.


More From » html

 Answers
179

If you control the Javascript library you mention, I would say the easiest way would be to manually trigger the change event every time you change a field's value.



I think this is how it's done in JQuery: Events/change Otherwise, a simple document.getElementById('myTextarea').onchange() might work as well.



If you have many calls, you could wrap the changing of the value, and the triggering of the event into a changeFormElement(id, value) function.



This requires, of course, that you can modify every instance of when a textarea is changed. If that is given, this is probably the most elegant way.


[#97821] Wednesday, January 13, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
trinity

Total Points: 591
Total Questions: 102
Total Answers: 106

Location: Singapore
Member since Sun, Jul 25, 2021
3 Years ago
;