Change event producing unexpected results
I am trying to set a function to be called on the change event of some textboxes with the classes "vii_year1", "vii_year2", "vii_year3", and "vii_year4".
Here is the code:
$(document).ready(
function
() {
for
(
var
i = 1; i <= 4; i++) {
var
year = i +
''
;
$(
".vii_year"
+ i).change(
function
(){
SetValidators(year);
})
}
})
The function I want to run is SetValidators, passing the year, 1 to 4. When the code executes, the year value passed is always 4, no matter what the class of the control. Can someone tell me what is happening here?