I am working on a non-employee accident reporting process. I am copying address information from information about the injured party (single line fields only) into a collection of witness information. The idea is that multiple witness could reside in the same household as the injured party (parent, sibling).
Within the collection I have a checkbox. When it is checked the injured party address populates the witness collection, but only for the first row. I have created other collections where Javascript is reused successfully on subsequent rows, but not based on a checkbox selection so I'm not sure what that entails. Thank you.
$(document).ready(function() {
$('.CopyInjuredAddress').change(function () {
var InjuredAddress = $('.InjuredAddress').find('input');
var WitnessAddress = $('.WitnessAddress').find('input');
var InjuredCity = $('.InjuredCity').find('input');
var WitnessCity = $('.WitnessCity').find('input');
var InjuredState = $('.InjuredState').find('input');
var WitnessState = $('.WitnessState').find('input');
var InjuredZip = $('.InjuredZip').find('input');
var WitnessZip = $('.WitnessZip').find('input');
if ($(this).find('input[value="Yes"]').is(':checked')) {
for (i = 0; i < 5; i++) {
$(WitnessAddress[i]).val($(InjuredAddress[i]).val());
$(WitnessCity[i]).val($(InjuredCity[i]).val());
$(WitnessState[i]).val($(InjuredState[i]).val());
$(WitnessZip[i]).val($(InjuredZip[i]).val());
}
} else {
WitnessAddress.val('');
WitnessCity.val('');
WitnessState.val('');
WitnessZip.val('');
}
});
});