Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ben 1 post 71 karma points
    Oct 10, 2020 @ 23:56
    Ben
    0

    Dynamically generating multiple input fields via Umbraco Heartcore

    I'm currently creating a form using Umbraco Heartcore and fetching all the form fields using the REST APIs to my frontend (React). However, one of the objectives is to create a question that takes in a number which would in turn dynamically create more input fields (questions) based on the number provided.

    enter image description here

    This example above illustrates what I'm trying to achieve. I have the first question "How many children do you have (if any)?", if the user inputs 2 I expect the "Child Name" input to conditionally appear twice, however it only appears once at the moment.

    Is it possible to dynamically generate multiple input fields based on user input from previous questions?

  • Lindow 154 posts 1301 karma points
    Feb 08, 2021 @ 05:08
    Lindow
    100

    Hey Ben.

    It's not possible to generate extra fields in a Form using an e.g. POST request, however, there's a workaround that I think could work for you.

    1. Change the "How many children" question to a dropdown and add a few values.

    2. Then add several Form fields with conditions as shown below.

      dropdown

    Let's say you want to have the dropdown with answers that range from 1 to 5.

    The first field will have 5 conditions like "dropdown is 1,2,3,4,5"

    The second field would have 4 conditions like "dropdown is 2,3,4,5" and so on.

    Hope this helps :)

    Best, Darek

Please Sign in or register to post replies

Write your reply to:

Draft