Programatically trigger an event w/ JS

  • killercelery
  • Newbie
  • Newbie
  • killercelery
  • Posts: 13
  • Loc: Montréal, Québec

Post 3+ Months Ago

Does anyone know if it's possible to trigger an event using JS?

I'm trying to trigger the onChange event of a text field when the code changes the current value contained in the text field. I tought the event might be triggered automatically, but it's not the case.

THX
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

I tried this and it seemed to work for me in IE and NE - it calls the onchange handler of the text field if that's what you want.

Code: [ Select ]
document.theForm.theTextField.onchange()


You can also do this for IE only:

Code: [ Select ]
document.theForm.theTextField.fireEvent("onchange")
  • killercelery
  • Newbie
  • Newbie
  • killercelery
  • Posts: 13
  • Loc: Montréal, Québec

Post 3+ Months Ago

Thanks, both work great!! :D

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 168 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.