show/hide and reset only once, when doc opens

Explorer ,
Jun 25, 2019

Copy link to clipboard

Copied

Hello all. I have a 3 page doc that I'd like to show/hide and reset certain fields only once. Once, at the time of opening the doc. I'm trying to have a fresh page every time I open the doc. Not, when navigating to the next page and then going back to the opening first page. I've searched a bit trying to find an example of javascript that will do the job without any luck. Can someone point me in the right direction to accomplishing this? Thank you for the help.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

253

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

show/hide and reset only once, when doc opens

Explorer ,
Jun 25, 2019

Copy link to clipboard

Copied

Hello all. I have a 3 page doc that I'd like to show/hide and reset certain fields only once. Once, at the time of opening the doc. I'm trying to have a fresh page every time I open the doc. Not, when navigating to the next page and then going back to the opening first page. I've searched a bit trying to find an example of javascript that will do the job without any luck. Can someone point me in the right direction to accomplishing this? Thank you for the help.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

254

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 25, 2019 0
Adobe Community Professional ,
Jun 26, 2019

Copy link to clipboard

Copied

Use the code at document open.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Most Valuable Participant ,
Jun 26, 2019

Copy link to clipboard

Copied

To elaborate: Go to Tools - JavaScript - Document JavaScripst and create a new item there. Remove the function definition that is created by default and replace it with your code. Save the file and the code will only execute once, when you open the file.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Explorer ,
Jun 26, 2019

Copy link to clipboard

Copied

I've tried to insert the code as you guys directed. It does what I want, but I click Save from the Menu (File>Save) to Save but then when I click to close the doc a window opens asking if I want to Save it again. Can I just Save one time? Instead of twice?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Most Valuable Participant ,
Jun 26, 2019

Copy link to clipboard

Copied

This should not happen if you only placed it as a doc-level script. Are you sure you didn't add it anywhere else?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Explorer ,
Jun 26, 2019

Copy link to clipboard

Copied

Heya Gilad, I only placed the script in the doc-level. But, it doesn't matter where I place it, it still does that thing. What I am finding out is, even if I do a Save As to Save the doc with a unique name and then I open that doc (with the script in the doc-level) it wipes out any of the fields so what to do. I want to Save the doc and the fields as I filled them in and leave the original alone. Perhaps that's the answer to having a clear doc when I open it. Do a Save As the very first, before I do any work. Wouldn't that kinda do the same thing and I would get to keep my work?

This is a bit of the script I placed in the doc-level -

if (opened < 1) {

opened ++ ;

  this.getField("Check Box1").display = display.hidden;

  this.getField("Check Box2").display = display.hidden;

  this.getField("Check Box3").display = display.hidden;

  this.getField("Check Box4").display = display.hidden;

 

  this.getField("Check Box10").display = display.hidden;

  this.getField("Check Box11").display = display.hidden;

  this.getField("Check Box12").display = display.hidden;

  this.resetForm("LineA"); 

  this.resetForm("LineB"); 

  this.resetForm("LineC"); 

  this.resetForm("LineD"); 

  this.resetForm("LineE"); 

} else {

// do stuff when the document has already been opened

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Most Valuable Participant ,
Jun 26, 2019

Copy link to clipboard

Copied

Yes, the code will run each time you open the file. Isn't that what you wanted? If not, then I don't understand how you want it to work...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Explorer ,
Jun 26, 2019

Copy link to clipboard

Copied

Yeah, I thought that's what I wanted but I'm learning as I go. I want to reset the doc but I don't want to lose the input I save. When I open the saved doc it also resets the fields so that means I won't be able to save my work, and that's what I want also. Right now I'm trying out the Save As feature. You are right with your directions, it's just me not knowing enough about what I'm doing.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Adobe Community Professional ,
Jun 26, 2019

Copy link to clipboard

Copied

Want you save the input or reset the form?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
try67 LATEST
Most Valuable Participant ,
Jun 26, 2019

Copy link to clipboard

Copied

I want to reset the doc but I don't want to lose the input I save.

This sentence is self-contradictory.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0