Re; Reset a form based on users checkbox selection

Avatar

Avatar

Yvette_s_Channe

Avatar

Yvette_s_Channe

Yvette_s_Channe

02-04-2021

I have a form with four check boxes.

 

Water, Soda, Ice, Plain

If the users toggles between them, I need the form to reset because they selected another checkbox. I would like the "Completed" button to clear all fields and subforms.

 

Thank you in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Magus069

MVP

Avatar

Magus069

MVP

Magus069
MVP

03-04-2021

Hi there,

 

First, do you have any experience with the software or JavaScript?

By the look of it, you seem to be working with radio buttons instead of check boxes. Radio buttons is a list of items which the user can only select 1 at a time. This is only technical question to start with, no intention to offense you.

 

To reset a form, you can always use the method xfa.host.resetData(); which will reset all fields to default value.

This method will also remove the user's new selection. To be able to reset only parts of the form you may want to add a subform's somExpression as parameter to reset only that part of the form. Let's say you want to reset multiple subforms at a time that does not contain the 4 main checkboxes you could use the following:

xfa.host.resetData(subFormWater.somExpression + "," + subFormSoda.somExpression + "," +  subFormIce.somExpression + "," + subFormPlain.somExpression);

the name preceding the "somExpression" should be the correct reference syntax to access the appropriate subform that relates to the 4 main options.

resetData function can only have 1 parameter at time, but you can concatenate all the parameters with commas into 1 string which will act as if you inserted multiple parameters.

 

In case that all the subforms are all in 1 subform, you can simply write one subform's somExpression.

xfa.host.resetData(subFormData.somExpression);

 

I hope this will help.

Let me know if you have any questions.

Answers (0)