I have this PHP script that generates a form:
for ($i = 1; $i <= 10; $i++) {
echo "<tr class='vraagrij'><td><select name='select" . $i . "'><option>1</option> <option>2</option></select></td><td><input type='text' value='Test' name='select" . $i . "'></td><td><select name='selectdos" . $i . "'><option>A</option><option>B</option></select></td></tr>";
}
What I need is to update the text in the input field of a specific row ONCE, whenever any element in that row has changed. So far I came up with this (I use css('color', 'yellow') for convenience and to easily see the behavior). But it only updates the changed element, and only once (since changed is set to 1, so I would need a new 'changed' per row, but I don't know how many rows there are going to be).
$( document ).ready(function() {
var changed = 0;
$('.vraagrij').children().change(function(e) {
if(clicked = 0)
{
var $parent = $(e.target).parent();
var $kids = $parent.children("input");
$kids.css('color', 'yellow');
changed = 1;
}
});
});