How to clear the values of a set of fields based on answers from another field?

  • Solomon_Moody
    Asked on April 23, 2025 at 6:15 PM

    How do I clear a set of fields if the selection on a radio button is changed? I have 4 groups of fields that are alike, one field in each group is used to make a calculation on a different field in the form. The second through 4th set of fields are set to appear if the radio button on the previous group is selected to YES. This then takes a number from one of the fields to make a following calculation. If the radio button is then changed back to no, the group is hidden again, but the calculation does not change. I have read that you can change fields to clear on hidden, but will that not clear any fields on the form if that section is collapsed, even if you don't change anything in the fields in that section?

  • John JotForm Support
    Replied on April 24, 2025 at 5:36 AM

    Hi Solomon,

    Thanks for reaching out to Jotform Support. I understand what you’d like to do, but I’ll need a bit of time to work out a solution. I’ll get back to you shortly.

    Thanks for your patience, we appreciate it.

  • John JotForm Support
    Replied on April 24, 2025 at 6:05 AM

    Hi Solomon,

    Thanks for reaching out to us for help. You can use the Section Collapse element to group your fields and set up conditional logic to show or hide these sections based on the radio button selection, you can configure the fields to clear when the section is hidden. This means when the radio button changes and the section collapses (hides), the fields inside that section can be cleared automatically. Let me show you how you can set that up:

    1. Open your form in Form Builder, click on the Add Form Element menu on the left side of the page.
    2. Scroll down to the Section Collapse element, then drag and drop it onto your form. You’ll need to add two of them, placing them before and after the fields you want to show or hide conditionally.
    3. Next, add a label to each one to make them easier to identify. How to clear the values of a set of fields based on answers from another field? Image 1 Screenshot 70
    4. Then, select the Section Collapse element, and click on the gear icon to open its properties page.
    5. In the menu on the right side of the page, set Section Visibility to Visible and Button Visibility to Hidden. How to clear the values of a set of fields based on answers from another field? Image 2 Screenshot 81
    6. Repeat the same step for the other Section Collapse element, and you're done.

    Now that the Section Collapse elements are in place, set up a condition to show or hide them based on the option selected in the preceding Single Choice field. Let me show you how:

    1. While in Form Builder, in the orange navigation bar at the top of the page, click on Settings.
    2. Click on Conditions on the left of the page.
    3. Now, click on Add Condition and then click on Show/Hide Field How to clear the values of a set of fields based on answers from another field? Image 3 Screenshot 92
    4. Set the condition like you see below: How to clear the values of a set of fields based on answers from another field? Image 4 Screenshot 103

    Finally, set the Clear Hidden Field Values option in your form settings to Clear when hidden. This ensures that any data in fields hidden by conditions will be removed automatically. Let me walk you through the steps:

    1. While in Form Builder, in the orange navigation bar at the top of the page, click on Settings.
    2. Click on Show More Options, then scroll down to Clear Hidden Field Values.
    3. Next, select Clear when hidden from the dropdown menu.

    How to clear the values of a set of fields based on answers from another field? Image 5 Screenshot 114

    And that's it. Check out the screencast below to see how your form will work after setting these up:

    How to clear the values of a set of fields based on answers from another field? Image 6 Screenshot 125 Give it a try and let us know how it goes.

  • Solomon_Moody
    Replied on April 24, 2025 at 7:52 AM

    If there are other collapsible sections on the form, will that not also clear them if they are collapsed?

  • Deanne JotForm Support
    Replied on April 24, 2025 at 11:14 AM

    Hi Solomon,

    If it's a normal section collapse, the data filled there will not clear when the user collapses it, but if it is conditionally hidden and you set it to clear fields when hidden as demonstrated by my colleague, then data will be cleared.

    Let us know if there’s anything else we can help you with.

Your Answer