You are viewing limited content. For full access, please sign in.

Question

Question

Populating information in repeated collection rows if checkbox selected

asked on November 22, 2022

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('');
 }
 });
 });

0 0

Replies

replied on November 22, 2022

I don't think your code is accounting for the fact that the other rows in the collection do not exist when the event handlers are being assigned, which is why it would only work on the first row.

The following post might help.

Table and Collection JavaScript Event Handlers - Laserfiche Answers

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.