Expand my Community achievements bar.

How to clear all data from a Subform when the presence attribute changes?

Avatar

Former Community Member
I have a form that shows either of two subforms based on a value selected from a drop-down list. So if "value 1" is selected, Subform1 is made visible (and Subform2 is hidden), and viceversa.



I need to clear all data (checkboxes, radio buttons, text) when a Subform becomes visible. Each subform contains about 7 objects.



Is there a code I can apply to the subforms (sort of like a "clear Subform Data" command) when it becomes visible, or do I need to do it for each object in the subforms?



Thanks.
2 Replies

Avatar

Level 6
Use xfa.host.resetData and pass it a SOM expression for the subform that you want to clear. Any fields with default values will be reset to their default values. Fields without defaults will be cleared.



In JavaScript (assuming your subform that you want to clear out is called mySubform):



xfa.host.resetData("xfa.form.form1.mySubform");



Jared Langdon

www.jlangdon.ca