These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Can Reset Button Restore the Initial Viewing State of a Form?

Registered: Aug 2 2010
Posts: 8
Answered

I am brand new to Acrobat, and an extreme novice when it comes to Javascript.

I have created a quote request form for work, where people fill out what they need our company to quote, and then are able to return it by email. I have included a reset button at the bottom of the form, so that whoever fills it out can erase everything they have entered, and start from scratch.

I was able to add code, which I found online, to warn people before resetting the form. If they click yes, the form resets, if they click no, it will not reset. That code works! I've copied that below.

if( app.alert({
cMsg: "Do you want to reset this form?",
cTitle: "Reset Form Warning",
nIcon: 2,
nType: 2
}) == 4) {
this.resetForm();
}

So here is the problem I am having. When I first open the form, certain fields are set to be hidden. These fields become visible when I perform a certain action within the form. For example, I ask if the company is tax exempt. There is a yes and no radio button. If the person indicates yes, then a text field becomes visible where they can enter the number. If I click no, the field is hidden. This field should ONLY be visible when the yes radio button is selected. However, if I have yes selected, and then press the reset button, it will deselect the yes radio button, but will not re-hide the text field.

How would I get the reset button to reset the viewing state of the form to the default of when it was first opened? i.e. hidden fields revert back to being hidden, and visible back to being visible.

My Product Information:
Acrobat Pro 9.3.1, Macintosh
smitchell15 (not verified)
In your buttons properties under the Actions tab, try choosing Show/hide fields. You can then select the fields and specify whether you want them to be visable or hidden;-) That should work for you?

Hope it does :)
Registered: Aug 2 2010
Posts: 8
Thanks for the suggestion, but I did already try that. If I do a show / hide mouse up event, it will automatically hide the field when I click on the reset button. I don't want that to happen. I only want it to hide the field if the user hits "yes" on the confirmation pop-up.

So, if the someone hits the reset button, it automatically asks if I am sure I want to clear the form. If they hit yes, I need the form to first be wiped clean, and then hide the field.

I did try to take out the pop-up confirmation off, and just have two actions set on the reset button. The first was to reset all the fields, and the second to hide the fields I need hidden. When I tested that, for whatever reason it would hide the fields, but not wipe them clean. i.e. I would then click the radio button to show the field again, and the text I had entered before pressing reset was still there. It's like the show / hide action is preceding the reset action.
smitchell15 (not verified)
Have you tried entering this?

this.getField("Text1").display = display.visible;
this.getField("Text1").display = display.hidden;
smitchell15 (not verified)
I just tested what you did with the two actions on the reset button and it worked this end, i even tried messing the order up so it wouldn't work but still did! Was these actions written via Javascript or via the actions panel? Sorry if this sounds simple but have you checked the reset form was configured and actually cleared the fields that you wanted?


I did try to take out the pop-up confirmation off, and just have two actions set on the reset button. The first was to reset all the fields, and the second to hide the fields I need hidden. When I tested that, for whatever reason it would hide the fields, but not wipe them clean. i.e. I would then click the radio button to show the field again, and the text I had entered before pressing reset was still there. It's like the show / hide action is preceding the reset action.
Registered: Aug 2 2010
Posts: 8
I'm sure I've got to be missing something simple, but I can't get it to work. Where do I add this.getField("Text1").display = display.hidden;?

I tried to enter it into the app.alert function as you see below, as well as in a second action where all the action says is this.getField("Comments").display = display.hidden;. Neither work. Where did you place the code? Thanks for all the help!

if( app.alert({
cMsg: "Do you want to reset this form?",
cTitle: "Reset Form Warning",
nIcon: 2,
nType: 2
}) == 4) {
this.resetForm();
this.getField("Text1").display = display.hidden;
}
Registered: Aug 2 2010
Posts: 8
smitchell15, thanks for all the help! I got it to work. The mistake I was making with
this.getField("Text1").display = display.hidden; is that I wasn't making the name of the field case sensitive. Apparently that made the difference. Thanks again!
smitchell15 (not verified)
Brilliant, glad you got it working :-) No problem at all!

All the best
Cheers
JONBR
Registered: Jan 14 2011
Posts: 1
Can Java script hide a range of fields? I'm asking because I have a similar form I want to revert to its original view, but have 63 fields (3 separate naming convention groups; X1 - X21, Y1 - Y21, Z1 - Z21 [examples; the actual text names are quite a bit longer]) and 4 different versions of the form with subtle differences. I think I may get carpal-tunnel trying to cut and paste code for each separate field I'd like re-hidden... Thanks in advance for any help to be offered.
maxwyss
Registered: Jul 25 2006
Posts: 255
You might rethink your field naming, and use hierarchical field names, which represent logical groups of fields. If you have to change the visibility of all fields within a group, one single line is sufficient.

If your field names can not be changed, you might create arrays of the field names you want to treat the same way, and then loop through these arrays and change the state.

HTH.

Max Wyss.