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

Question

Question

New Form Designer JS

asked on December 5, 2023

Hi Community,

Any one can translate this code to the New Form Designer?

"$( document ).ready(function() {
  
  // Run visibility checker on page load
  toggleVisibility();
  
  // Runs when the radio button is changed
  $( ".radio1" ).change(function() {
    toggleVisibility();
  });
  
  // Makes button visible if No
  function toggleVisibility(){   
    if ($('input[name="Field1"]:checked').val() == "No"){
      $('.radio2 input').prop('checked', false).change();
      $('.radio3 input').prop('checked', false).change();
    }
  }
});"

I'm not good in javascripting.

 

Thank you

0 0

Replies

replied on December 5, 2023

There shouldn't be a need for you to use JavaScript for this in the new Forms Designer. You should be able to accomplish the same thing using Field Rules.

1 0
replied on December 7, 2023

@████████ is correct, you should be able to accomplish this with field rules in the new form designer. Without seeing the form, it is difficult to know what the code inside your toggleVisibility function is doing. You can set values of any field on the form with the LFForm object in layout designer as well as listen to field changes. Please checkout the documentation and let me know if you have any questions.
On Field Changes
Set Field Values

0 0
replied on December 10, 2023

Hi @Blake Smith and @████████,

Thank you for replying to my query.

 

I want to now how to clear another radio button when first radio button make changes is made. In classic form code above is working fine, but in new form I cannot do it.

 

Thank you

 

 

0 0
replied on December 11, 2023

Radio buttons do not natively support being deselected in the new form designer. Once an option is selected it is required to have an option set. Maybe create a new "blank" option to set under the circumstances you require.

0 0
replied on December 11, 2023

In classic form using the code, it's able to deselect the other ratio button value.

There's no other way in new form to do it? 

0 0
replied on December 14, 2023

I stand corrected, I tested this just now. Using the below function you can "blank out" a radio button in the new form designer.

 

LFForm.setFieldValues({ fieldId: 4 }, "")

 

2 0
replied on December 15, 2023

I will try @████████.

 

Thanks

0 0
replied on January 25, 2024

This worked 

LFForm.setFieldValues({fieldId: 4}, {value: []});

 

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

Sign in to reply to this post.