In my form I have five radio groups like this:
<label class="radio-inline"><input type="radio" name="persontype1" value="fo" checked="checked">FO</label>
<label class="radio-inline"><input type="radio" name="persontype1" value="po">PO</label>
and then I have a loop to hide/show other elements, based on change event of those radiobuttons:
for (i = 1; i <= 5; i++) {
$("input[type=radio][name=persontype" + i + "]").change(function() {
if (this.value == 'fo') {
$("#person-name" + i).removeClass('hidden');
}
else if (this.value == 'po') {
$("#person-name" + i).addClass('hidden');
}
});
}
The problem is that it doesn't work this way. When I use absolute ID value name in the selector, it works:
$("#person-name1").addClass('hidden');
I've tried to use some global variable but it didn't work either. Is there a way how to pass variable i to that function?
Thanks in advance, JiKra