grippat Posted December 12, 2007 Share Posted December 12, 2007 I'm trying to figure out how to add an event listener to every input tag. I had this:document.getElementsByTagName('input').onkeyup = function () {alert('testing');}But it didn't seem to do anything. My objective is to have JavaScript send entered form info via AJAX every time the user presses a key. There are multiple inputs so I need the same even listener on each. Link to comment Share on other sites More sharing options...
Ingolme Posted December 12, 2007 Share Posted December 12, 2007 Make sure you run this code AFTER the window has loaded (for example put it in a function and call it with the window.onload event).inp = document.getElementsByTagName("input")for(i=0;i<inp.length;i++) {inp.onkeyup = function () {alert('testing');}} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.