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

Read only button toggle

New Here ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Hello all,

I'm trying to make a fillable form where the front desk reps fill out a certain portion of the form and then the form is sent to patients to sign and fill out. To avoid patients from editing what the front desk has filled out im trying to make a button that locks the fields to read only. I have the code to set the text field to read only but I would like the text fields to be editable again if the button is unchecked in case the front desk needs to go back and fix something. Is this possible? The code I have for the button to set it to read only is this.getField("FieldNameHere").readonly = true;

 

Thank you for any help!

TOPICS
JavaScript , PDF forms

Views

733

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

Community Expert , Mar 17, 2021 Mar 17, 2021

Assuming it's a check-box field, and you've placed the script udner its Mouse Up event, you can adjust your code like this:

 

this.getField("FieldNameHere").readonly = (event.target.value!="Off");

Votes

Translate

Translate
Community Expert ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Assuming it's a check-box field, and you've placed the script udner its Mouse Up event, you can adjust your code like this:

 

this.getField("FieldNameHere").readonly = (event.target.value!="Off");

Votes

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
New Here ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Yes, it is a check-box field. Aplogies I should have been more clear. This worked perfectly!

 

Thank you!

Votes

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
New Here ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Thank you for your help. I just have one more question. Is there a code that locks that check box button after it has been saved? 

Votes

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
Community Expert ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

What has been saved? The file? If so, you should do it just before it's saved, not after.

To do it go to Tools - JavaScript - Set Document Actions and under the Document Will Save event enter the following code:

this.getField("FieldNameHere").readonly = true;

Votes

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
New Here ,
Jan 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

I'm trying to do something somewhat similar but need a button to unlock certain fields. I also need this button password-protected or something. I need people to fill out the top portion first and have some form fields at the bottom locked for certain personnel. Is there a code to put a password on the button and have that button turn off read-only for those certain fields?

shelby342893912t7v_0-1705536241344.png

 

Votes

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
Community Expert ,
Jan 18, 2024 Jan 18, 2024

Copy link to clipboard

Copied

You can do it using something like this:

 

if (app.response("Enter password to unlock fields:", "", "")=="1234") {
	this.getField("Field1").readonly = false;
	this.getField("Field2").readonly = false;
	this.getField("Field3").readonly = false;
} else app.alert("Wrong password!");

 

Notice the correct password is hard-coded into the script as plain-text ("1234" in the code above), so it's extremely unsecure...

Votes

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
New Here ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

LATEST

That worked beautifully, can you provide code for making the button reverse the "AGI admin personnel signature" and "Decision" fields being set to the read-only using the button?

Votes

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