These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

button to change read-only to open and then back to read-only

suewhitehead
Registered: Jun 3 2008
Posts: 232
Answered

I would like to make a button in an Acrobat form that will change a field from read-only, then allow the user to change the data in the field, then make the field read-only again when they are finished. I currently have the script that will change it from read-only, but then it leaves it as read-only unless they click on the button again. I would like to eliminate the chance that they will not remember to click it the second time to change it back to read-only.

Here is my current script:
var f = this.getField("SendTo");
var cChangeContactInfo = app.alert("Do you want to edit the Send To information?\n\nClick YES to enter new contact information and then click this button again. \nClick NO to lock the contact information as read-only. \nClick CANCEL to leave it as is.",2,3,
"Change Contact Info");

if (cChangeContactInfo == 4)
{ f.readonly = false;
}
else
{
f.readonly = true;
}

Thanks for any help.

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
If you're saying that you want the field to automatically revert to read-only when the user makes a new entry, there are a number of ways you can do it. Probably the most straightforward way would be to use the following in the field's On Blur event:

// Set this field to readonlyevent.target.readonly = true;

George
suewhitehead
Registered: Jun 3 2008
Posts: 232
George,
This is exactly what I figured out after I posted my question. It works great.
Great minds think alike, right?

Thanks for your help and for making me feel smart!