I have a table where one of the td cells has a input type=text
field. Each row in the table has something like this:
<td class="expected_minutes">
<input id="minutes-980" class="minutes" type="text" value="39" name="minutes-980">
</td>
Now what I'm trying to do is change the value in another cell if the user changes the value in this particular one. It doesn't necessarily have to be done when the user is done changing text. It can be whenever the value in the text box changes at all -- whatever works best. Here's some code I found on SO to get me started:
//setup before functions
var typingTimer; //timer identifier
var doneTypingInterval = 2000; //time in ms
//on keyup, start the countdown
$('.minutes').keyup(function(){
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
//on keydown, clear the countdown
$('.minutes').keydown(function(){
clearTimeout(typingTimer);
});
//user is "finished typing," do something
function doneTyping () {
console.log("DONE TYPING");
}
The problem I've found here is this code was most likely targeting an application with a single input text box. I have several rows where each row has one and I need to run some code when the minutes value in that particular row has been modified.
Is there anyway I can make this work for all of the text boxes in my table?