I have two subforms that are either shown or hidden based on a radio button selection.
If Radio Button "1" is selected, subform1 is visible and subform2 is hidden and vice-versa.
This is hard for me to explain, so please bear with me.
What I want to do is to clear the subform fields if you switch back and forth between subforms.
For example:
1. Click Button "1" (subform1 visible)
2. Fill in subform1 fields.
3. Click Button "2" (subform1 now hidden)
4. Click Button "1" (subform1 is visible and fields are blank)
I found the below script in another post for a similar problem. I put it as a "click" event for each Radio Button Item, but I'm not sure where it's supposed to go as the other post didn't say. It works but it clears the entire form, not just the subform fields.
xfa.host.resetData("xfa.form.form1.subform1");
Can anyone tell me the proper script to make my form work?
Please keep it simple. The extent of my JavaScript knowledge is basically cut and past and hope it works. If it does work, it's by the grace of God only. I couldn't tell you the difference between a SOM and an node.
So, if anyone has an answer, please dumb it down to about the level of a third grader.
Solved! Go to Solution.
Based on your Hierarchy the command to reset of al the fields in Subform1 woudl be:
xfa.host.resetData("form1.Page1.Subform1");
If you want to reset the data in more than one object you can separate them with commas like this:
xfa.host.resetData("form1.Page1.Subform1", "form1.Page1.Subform2");
Note that the commands are case sensitive ...you were using a lowercase s in subform as well the expression in quotes does not start with xfa.
The command will go in between the curly brackets in the section where you test the radioButton to the value that you want.
If you want to reset when the user picks Yes then put it in the if section. If you want it when they pick No, put it in the else section.
Paul
Views
Replies
Total Likes
That is the right command and you woudl do it right after you change the presence of the subform. The issue might be that you are not pathing to your subform correctly. Look at your hierarchy view and see that you do have a form1 and a subform1 node.
Paul
Views
Replies
Total Likes
Paul,
Thanks for responding.
I'm still confused as to which field the script goes in and how to enter it in relationship to any existing script.
Instead of me trying to explain verbally, I'll show you what I have.
Document Hierarchy:
Subform path & script: (I'm assuming I need one for each subform)
xfa.host.resetData("xfa.form1.Page1.subform1");
xfa.host.resetData("xfa.form1.Page1.subform2");
"Radio Button List" Click Event script that shows/hides subforms:
form1.Page1.FLOC.RadioButtonList::click - (JavaScript, client)
if (this.rawValue == 1)
{
Subform1.presence = "visible";
Subform2.presence = "hidden";
}
else if (this.rawValue == 2)
{
Subform2.presence = "visible";
Subform1.presence = "hidden";
}
if (this.rawValue == 1)
{
Efficiency.presence = "visible";
}
if (this.rawValue == 2)
{
Efficiency.presence = "visible";
}
I've tried putting the script inside the curly brackets, outside the curly brackets, at various locations within the above script, but no matter where I put it, it clears the entire form.
Would you be so kind as to re-write the above script properly so I can see what it's supposed to look like.
Thanks!
Views
Replies
Total Likes
Based on your Hierarchy the command to reset of al the fields in Subform1 woudl be:
xfa.host.resetData("form1.Page1.Subform1");
If you want to reset the data in more than one object you can separate them with commas like this:
xfa.host.resetData("form1.Page1.Subform1", "form1.Page1.Subform2");
Note that the commands are case sensitive ...you were using a lowercase s in subform as well the expression in quotes does not start with xfa.
The command will go in between the curly brackets in the section where you test the radioButton to the value that you want.
If you want to reset when the user picks Yes then put it in the if section. If you want it when they pick No, put it in the else section.
Paul
Views
Replies
Total Likes
Paul,
I followed your instructions and it works great......thanks!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies