You are viewing limited content. For full access, please sign in.

Question

Question

Uncheck a radio button??

asked on March 30 • Show version history

Hello, 

 

I have a form that uses questions via radio buttons to guide them to the form they need to fill out. Mostly yes and no questions. The questions are hidden until the previous question is answered with the specific answer. But I've noticed that if you go back and change your answer, the previously answered questions are now still visible because they were previously answered. But they do not relate to the path that has now changed. Is there a way for the radio buttons to be unselected when hidden? 

Step 1.jpeg
Step 2.jpeg
Step 1.jpeg (120.82 KB)
Step 2.jpeg (115.38 KB)
0 0

Answer

SELECTED ANSWER
replied on March 30

Hi, that form is in Modern Design or Clasic Design? 

0 0
replied on March 30

This is in the modern forms designer. 

1 0
replied on March 30 • Show version history

Try to apply and adjust this code in the JS Form tab: 

// ============================================================
//  CONFIGURATION — Only edit this section
// ============================================================

// DEPENDENCY_MAP defines which fields should be cleared
// whenever a trigger field changes its value.
//
// Structure:
//   triggerFieldId: [fieldId_to_clear, fieldId_to_clear, ...]
//
// Left side of the colon  → the field the user interacts with (trigger)
// Inside the brackets [ ] → the Field IDs of the radio buttons
//                           that should be cleared when this trigger changes
//
// Example:
//   1: [2, 3, 4, 5, 6]
//   means: "When Field 1 changes, clear the radio buttons
//           in Fields 2, 3, 4, 5, and 6"
//
// To add more fields, just add their Field IDs inside the brackets:
//   1: [2, 3, 4, 5, 6, 7, 8]  ← Field IDs 7 and 8 would also be cleared
//
// To add a new trigger, add a new line following the same pattern:
//   6: [7, 8]  ← When Field 6 changes, clear Fields 7 and 8
//
// Find your Field IDs in the Form Designer by clicking on each
// field and checking the Field ID shown in the properties panel.

const DEPENDENCY_MAP = {
  1: [2, 3, 4, 5, 6],  // Field 1 trigger → clears radio buttons in Fields: 2, 3, 4, 5, 6
  2: [3, 4, 5, 6],     // Field 2 trigger → clears radio buttons in Fields: 3, 4, 5, 6
  3: [4, 5, 6],        // Field 3 trigger → clears radio buttons in Fields: 4, 5, 6
  4: [5, 6],           // Field 4 trigger → clears radio buttons in Fields: 5, 6
  5: [6],              // Field 5 trigger → clears radio buttons in Field:  6
};

// ============================================================
//  LOGIC — Do not modify anything below this line
// ============================================================

function clearDependents(triggerFieldId) {
  const dependents = DEPENDENCY_MAP[triggerFieldId] || [];
  dependents.forEach(function (depFieldId) {
    LFForm.setFieldValues({ fieldId: depFieldId }, { value: "" });
  });
}

Object.keys(DEPENDENCY_MAP).forEach(function (triggerId) {
  LFForm.onFieldChange(
    function () {
      clearDependents(Number(triggerId));
    },
    { fieldId: Number(triggerId) }
  );
});

Let me know if it works

4 0
replied on April 1

Thank you so much Luis! This was perfect. 

1 0
replied on April 1

Great, it's good to know. If you can mark it as the correct answer so other members can see that approach, it could be useful.

1 0

Replies

replied on March 30

Can you share a screenshot of the field rules you're using to show/hide fields based on the selected radios?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.