This help desk is no longer actively support. We have switched to a ticketing system to more smoothly manage support, and free up development time. Your newly created tickets won't be available here. You will instead have an email history of your new tickets.

We are working on moving everything current and helpful from public tickets into the docs. This will be a long process and in the meantime, public tickets will remain searchable.

Your private tickets will remain available to you indefinitely. See your old tickets.

Help Desk

Add a default value to a parent field from a repeating section field

Labels

This Ticket is public

Notifications

Hi,

Is it possible to pass on the value of the first row only from a repeating section field to a field in the parent form?

For example, if the repeating section had a field called "First Name", I would like to be able to pass on the first entry to a field called "Parent's First Name" in the main form.

If I use the "Calculate the default value for this field" and put the [First Name] (using the field ID) on "Parent's First Name", I get all the values (i.e. Michael, Adam, Suresh, Michiko).  I want to be able to pass on "Michael" only and not the whole list.

Is this possible?

Thanks!
Victor

Hello,

This would require custom javascript to only get the value from the first row of the repeater and insert it into a field elsewhere in the form.

Custom code is not covered by our support, however we have some examples that might help you get started:
https://formidableforms.com/knowledgebase/javascript-examples/

Do you have any questions on this?

Thanks, Matthew! Worked like a charm.  Here's the code for anyone else who'd care to use it:

<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
copyValueFromRepeat();

var sourceFields = document.querySelectorAll( '.frm_field_84_container input');
sourceFields[0].addEventListener( "change", function(event) {
copyValueFromRepeat();
});

});

jQuery(document).on('frmAfterAddRow', copyValueFromRepeat );

function copyValueFromRepeat(){
var sourceFields = document.querySelectorAll( '.frm_field_84_container input');
var mainField = document.getElementById( 'field_w1r3t' );
mainField.value = sourceFields[0].value;

}
</script>

where '84' .frm_field_84_container is the ID of the field in the repeating section you'd like to copy; and,

'field_w1r3t' is the key of the text field in the main form.

Please make this ticket public as it may be useful for someone else.

Cheers,
Victor

 

 

Ticket closed.