function populateRemainingFields(el,groupId) {
// get the element value ...
var x = el.getValue();
// if checkbox is checked
if (x==1){
insertValue("no",el,groupId)
// if the checkbox is unclicked lets remove all the data
}else{
// if the check box is checked append new data to remaining fields
insertValue("delete",el,groupId);
}
}
function insertValue(remove,el,groupId){
// get the repeat group on which checkbox was clicked
var myForm = 'form_1'
var targetRepeatCount = getRepeatCount(groupId);
var block = Fabrik.getBlock(myForm);
// find how many repeat groups are open
var numRepeats = block.repeatGroupMarkers[groupId];
jQuery.each(el.form.formElements, function(key, element) {
//Is this the same group as clicked checkbox
if (element.groupid == groupId) {
// do not include id items, add 'id' to element name to exclude it
if (key.indexOf('id')== -1) {
//from key trim off the number of the repeat group and add #
var targetField = ('#' + key.slice(0, -1));
//get the value to be copied
// if the checkbox is checked onclick use the value in the group, if not clear the field
if (remove == "delete"){
var targetValue = "" // jQuery(targetField + targetRepeatCount).val();
}else{
var targetValue = jQuery(targetField + targetRepeatCount).val();
}
//add 1 to group count
var newTargetRepeatCount = targetRepeatCount + 1
do {
//update the rest of the groups with the value
//console.log(targetField+newTargetRepeatCount,"=",targetValue);
jQuery(targetField + newTargetRepeatCount).val(targetValue);
newTargetRepeatCount = newTargetRepeatCount + 1;
}
while (newTargetRepeatCount < numRepeats);
}
}
});
}
function getRepeatCount(groupId){
// get the DOM object for this group ...
var thisGroup = jQuery('#group' + groupId);
// get a jQuery array of all the subgroups in this group ...
var allSubGroups = jQuery(thisGroup).find('.fabrikSubGroup');
// get the sub group the button was clicked on ...
var targetSubGroup = event.target.getParent('.fabrikSubGroup');
// find the index of the target subgroup in all groups
var RepeatCount = jQuery.inArray(targetSubGroup, allSubGroups);
return RepeatCount;
}