Make all form fields read only except generated template page

Explorer ,
Dec 04, 2020 Dec 04, 2020

Copy link to clipboard

Copied

I have a two page form that once the user fills out and signs they click the submit button. The submit button has added to it a action mouseup javascript that makes all the fields read only and also generates a template page that is for admin use. So the idea is that once the form is submitted the person receiving the form on the other end will not be able to touch the fields on the first two pages but in the third page generated from the template.

 

I have two scripts running in the button plus submit form:

The first to generate the template page and hide two buttons:

var a = this.getTemplate ("AdminUse");
a.spawn();
this.getField("Submit").display = display.hidden;
this.getField("Reset").display = display.hidden;

 

The second to make all fields read only:
//getField("Text_Field").readonly = true;
for(var i=0;i<this.numFields;i++)
{
var fieldName = this.getNthFieldName(i);
if (fieldName == "FOR_ADMINISTRATION_USE_ONLY")
{
//console.println(i+":no:"+fieldName);... used in the debugger
}
else
{
//console.println(i+":"+fieldName);... used in the debugger
getField(fieldName).readonly = true;
}
}

 

The second script is making everything read only. Which is almost what I want but not quite. I need the field named "FOR_ADMINISTRATION_USE_ONLY" to remain fillable. Please help. What is wrong with the script? I'm struggling to find the correct solution to make that one field fillable.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

114

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Dec 07, 2020 Dec 07, 2020
Couple of issues: 1. You should not have split the code to two "Run a JavaScript" actions, since you can't control the order in which they are executed. Combine them to a single command, as well as the Submit Form action. 2. There's an error in your code. There's no field called "Reset", so this line fails: this.getField("Reset").display = display.hidden; Change it to: this.getField("Reset Form").display = display.hidden; 3. You're spawning the Template using the default settings, which means th...

Likes

Translate

Translate
Adobe Community Professional ,
Dec 05, 2020 Dec 05, 2020

Copy link to clipboard

Copied

The code seems fine... Are there any error messages when you run it? Are you sure you spelled the field name correctly?

Can you share the actual file with us?

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
community guidelines
Explorer ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

I can share a modified version. How can I do that?

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
community guidelines
Adobe Community Professional ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

You can attach it to the original message using the tiny paperclip icon at the bottom when you edit it, or upload it to a file-sharing website (like Dropbox, Google Drive, Adobe Cloud, etc.), generate a share link and then post it here.

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
community guidelines
Explorer ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

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
community guidelines
Adobe Community Professional ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

Where's the script located?

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
community guidelines
Explorer ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

In the submit button

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
community guidelines
Adobe Community Professional ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

Couple of issues:

1. You should not have split the code to two "Run a JavaScript" actions, since you can't control the order in which they are executed. Combine them to a single command, as well as the Submit Form action.

2. There's an error in your code. There's no field called "Reset", so this line fails:

this.getField("Reset").display = display.hidden;

Change it to:

this.getField("Reset Form").display = display.hidden;

3. You're spawning the Template using the default settings, which means the fields in it are renamed, so there's no field called "FOR_ADMINISTRATION_USE_ONLY" afterwards.

Change the spawn command to:

a.spawn({bRename: false});

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
community guidelines
Explorer ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

How do I combine it with the submit form action?

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
community guidelines
Adobe Community Professional ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

Use this command:

 

this.submitForm({cURL: "mailto:staceykosedy.4@gmail.com", cSubmitAs: "PDF"});

 

PS. You forget the "mailto:" part in your Submit a Form command, so that wouldn't have worked, either...

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
community guidelines
Explorer ,
Dec 08, 2020 Dec 08, 2020

Copy link to clipboard

Copied

LATEST

Ok thank you. I had mailto in there before I modiefied it. Sorry about that. Thanks so much for your help. It works great. I thought that if I stacked the javascript as separate scripts it would control the order it happened. Thank you for clarifying.

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
community guidelines