Hello,
I am banging my head against the wall with this one and I know the answer will be something simple.
I have a form where hidden subforms are made visible via a dropdown. I want my reset button to reset all the data in the form but also then make these subforms hide again - so taking the form back to its original state.
I can't figure out the script that goes behind the button. Would anyone kindly help?
Many thanks,
Nicola
Hi,
After the reset script you can add a line for each dropdown that controls the presence of a subform.
For example if DropDown1 has script in its exit event that controls the presence of a subform, then in your reset button you could have the following:
// General reset
xfa.host.resetData();
// hide subform
page1.DropDown1.execEvent("event");
Alternatively, you can just set the presence of the subform to invisible/hidden directly from the reset button.
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
thanks for replying, I'll give that a try.
Incidentally, what would the script be to set the presence of teh subfomr to hidden directly from the reset button. I can't seem to figure out how to write teh script in conjunction with restting the data.
Nicola
Views
Replies
Total Likes
Hi Nicola,
It would be the same basic approach - click event of reset button:
// General reset
xfa.host.resetData();
// Hide subform
page1.Subform2.presence = "hidden";
The trick is to make sure that your relative reference from the reset button to the subform is correct. Check out this example here about referencing objects, if you are having difficulty: http://assure.ly/kUP02y.
It all depends on how you are naming your pages and subforms AND if there are multiple subforms with the same name.
Hope that helps,
Niall
Wow, you have some good suggestions--but not the right answer. Here's the deaL you want to reset the form back to its original state--not just clear the fields. This was a source of frustration for me until I figured it out.
Decide on the trigger (i.e. click, exit, whatever, doesn't matter) and use the following script:
xfa.host.resetData();
xfa.form.remerge();
That's it! It does the trick--and it's not hard. Wow! I love this solution. I think you will too.
Best,
Stephen
Good catch Stephen. I didn't realise remerge() would do that. Learn something new everyday! Niall
Views
Replies
Total Likes
Niall and Stephen,
thanks so much for your help with this - both options worked fine and did exactly what I wanted.
regards,
Nicola
Views
Replies
Total Likes
Thanks Niall,
I produce very complex forms that get used frequently--often multiple times in day-- by a limited number of users. These folks might want to keep the form open, rather than close and re-open the form in order to use it again. These forms resemble an application. Like the application MS Word, for instance, it would be silly if you had to close MS Word and re-open it just to start a new document.
I removed the regular Reset Buttons since they didn't really reset the form and let the user start another. I cannot remember how I came accross the remerge() solution--I believe it was quite by accident. But when I did, I was stunned and rejoyceful at the same time--you could have knocked me over with a feather!
It is simple and elegant.
Sometimes, even a blind squirrel finds a nut.
Stephen
kingphysh thanks a lot for posting the answer. I used it on a form and it worked great.
I had used the .presence = "hidden"; syntax but since I had many fields that needed to go back to hidden it would take a long time.
Views
Replies
Total Likes
If you try this and end up with dynamic table rows still left there is a closely related post showing how to reset the tables to their unpopulated state at Reset Dynamic Form with multiple tables
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies