![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi All, I'm creating textareas via the DOM and I'm trying to add the onchange event to them. *Here's my code: mytextarea = document.createElement("textarea"); mytextarea.onchange = mymethod; mytextarea.name = "textarea1"; mytextarea.value = ""; . . . In another script file, I have the mymethod() function defined like this: function mymethod() { . . . } I tried various incarnations of setting the onchange event: mytextarea.onchange = "mymethod()"; and onchange = "mymethod";. *None of which works. *What's the secret to dynamically defining the onchange event? |
#3
| |||
| |||
|
|
On Jun 3, 2:08 pm, HugeBob <rnu... (AT) gmail (DOT) com> wrote: Hi All, I'm creating textareas via the DOM and I'm trying to add the onchange event to them. Here's my code: mytextarea = document.createElement("textarea"); mytextarea.onchange = mymethod; mytextarea.name = "textarea1"; mytextarea.value = ""; . . . In another script file, I have the mymethod() function defined like this: function mymethod() { . . . } I tried various incarnations of setting the onchange event: mytextarea.onchange = "mymethod()"; and onchange = "mymethod";. None of which works. What's the secret to dynamically defining the onchange event? The following worked for me: mytextarea.onchange = function() { mymethod(); }; |
#4
| |||
| |||
|
|
The following worked for me: mytextarea.onchange = function() { mymethod(); }; |
![]() |
| Thread Tools | |
| Display Modes | |
| |