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.
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.
Copy link to clipboard
Copied
Use the code at document open.
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.
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?
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?
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
}
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...
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.
Copy link to clipboard
Copied
Want you save the input or reset the form?
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.