Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Acrobat form javascript

Community Beginner ,
Dec 18, 2019 Dec 18, 2019

Hello all.

 

I have a few questions and need your help for that.

 

I am making a checklist for my company for checking the designs and files we put out there.

Now the questions are:

 

1. I want the document to be only save as, this is so people can't overwrite the file. So when you open it, it will always be an unfilled form. So people can fill it the form, but can't normaly save or edit it.

 

2. We have different kind of status modes for waiting on agreement of the client and waiting for files and many more. Now I already have a buttons for the status modes:

image.pngexpand image

What I would really like is when I hit the checkmark, the date of today (Datum=Date) will be automatically filled on the dotted line. This is probably done by Javascript.

 

I hope you guys can help

TOPICS
Edit and convert PDFs , General troubleshooting , How to , PDF forms , Security digital signatures and esignatures , Standards and accessibility
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Hi,

I will not answer to the first question, but I don't think it is possible to lock the "Save" Menu function.

For the 2nd question, place this script in calcul of each date field:

if (this.getField("CheckBox").value!="Off") {
if (event.value=="") event.target.value=new Date();
} else {
event.value="";
}

these field must set with a date format.

@+

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Hi,

I will not answer to the first question, but I don't think it is possible to lock the "Save" Menu function.

For the 2nd question, place this script in calcul of each date field:

if (this.getField("CheckBox").value!="Off") {
if (event.value=="") event.target.value=new Date();
} else {
event.value="";
}

these field must set with a date format.

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2019 Dec 18, 2019

Thanks man, the script works.

Now how can I auto activate it, so without to click the text field?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

That code is not entirely correct. Use this instead:

 

if (this.getField("CheckBox").value!="Off") {
event.value=new Date();
} else {
event.value="";
}

 

When you tick (or un-tick) the corresponding check-box it should populate (or clear) the text field automatically.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Like that the date will change each time the file is open at an other date...

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

No, it won't, as opening the file doesn't trigger calculation scripts.

However, you are correct that it will update each time any field in the file is changed.

If you want it to only happen when the check-box is ticked then it needs to be differently, via the Mouse Up event of the check-box itself.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2019 Dec 18, 2019

And what if I would do it through the javascript tool:

 

if (this.getField("Akkoord").value!="Off") {
if ("Akkoord_Datum".value=="") "Akkoord_Datum".target.value=new Date();
} else {
Akkoord_Datum.value="";
}

 

Would this work?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Like that, the script fill the field only if it is empty, so the date will not change if there is already one indicated in the field.

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

No, it won't. That script contains errors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019
LATEST

You are twice right!

1) I answered fron my phone and I didn't check the script and it is effectively wrong. I though it was the one I gave.

2) No need to add “if (event.value==""”... I checked! However, that's what I do every time.

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

1. Set the file and the folder of the file as read-only.

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