Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
English
In this article, we will demonstrate how to retrieve values from a subform. We'll use a simple app as an example, where we read the value from the subform and set it in a form field.

Form Design

Subform Design

Image RemovedImage Added

Make sure to remember the Form ID of your subform, it will be necessary for your Custom HTML.


Parent Form Design

Image RemovedImage Added


Custom HTML

This is the Javascript code that reads the value of the subform and sets the field value.

Code Block
titleJavascript
<script>
    $(document).ready(function(){
        selectmain = $(FormUtil.getField("field1")); //Get ID of subform
        selectmain.on("change",function(){
            setTimeout(function(){
                select1my_name = $("#field2_subform_name"); //Get subform value
                my_country = $("#field2_subform_country");
                my_date = $("#field2_subform_date");
                var field1 = FormUtil.getField("field3"); //Get field of form
                var field2 = FormUtil.getField("field4");
                $(field1).val(select1my_name.val()); //Set field to value of subform
                $(field2).val(my_country.val());
            },100);
        });
    })
</script>


Runtime

This is the result of the above code:

Image RemovedImage Added

Image RemovedImage Added


Download the sample app below:

...