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

Show/Hide a Field and Make a submitted Form Read Only

prander
Registered: Nov 6 2008
Posts: 44

I have created a form letter that acts as a class confirmation for the admin assistant to use. When she hits a "Click to E-mail" OK button, I created it to hide the OK button. Further Actions for this same button above the Show/Hide Field script include, "Execute a menu item-File>Save As...,-Submit a form" Additionally, this is an enabled form so that she might save it before sending the completed attachment.
 
For some reason, the final version that is received by the student (via e-mail attachment) contains a visible "Click to E-mail" OK Button.
 
Also in using the form (I'm the admin today!), I realized that I'd like for all the form fields to become "read only" on the version that is saved and sent to the student.
 
So: Can I hide the OK button when it's saved and sent AND can I enable all the form fields to be "read only" before/as it's saved and sent?
 
Thanks,
Page

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
All those things are doable. Most of them require scripting. But much of this information has been discussed several times on this forum. For example, locking or setting fields to Read Only. Search for "read only on save" or "locking fields".

You've listed several issues here. I'd suggest posting a new thread for each individual issue and provide a short but thorough explanation, you'll get a better response that way.

You can hide a button with the script
fieldName.presense = "invisible";

But be careful how the code is applied. If it's done on every save, then how will it ever be used? What if the form is saved before it's completed, and the person will try to complete it later?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

prander
Registered: Nov 6 2008
Posts: 44
Before posting my query, I did a search for "Read only on a completed form" and I came up with nothing usable.

Many of the answers to your suggested query ("read only on save") were unanswered and others were duplicated on my original query. Several others were for LiveCycle and I haven't learned to use that. It took to page 3 to find a usable answer and it redirected me to Adobe Forums.

Answer supplied in this post: http://forums.adobe.com/message/3239586#3239586
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Opps, I was under the impression you had a LiveCycle form. In that case fields are hidden with this code:

this.getField("MyField").hidden = true;

And are set to read only with this code

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

I assume that you want the fields to be made read only when the form is successfully submitted, and only when the form is successfully submitted? The first problem with this is that the script has know way to know whether or not the form actually submitted. But we can assume it submitted if all the required fields are filled in properly.

The general strategy is for the submit button to run the form level validation script, if successful the script then activates the submit. This is quite a bit of scripting.

You can read more about it here:
http://www.pdfscripting.com/public/department46.cfm


Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

K1K1
Registered: Aug 27 2010
Posts: 3
I'm not to familiar with the readonly function, but I have found this script that activates the readonly function for all form fields as the button is being submitted to be sent as an email attachment.
var fFc = this.numFields ;
var FieldName = ''
for (var f = 0; var s = 1; s < fFc; s++){
FieldName = this.getNthFieldName(s)
var fFn = this.getField(FieldName);

fFn.readonly = true;
}

It works for me, but I need and extra step I need for one button to remain functional wich in my case is the print button. When my end users submitt the form to be emailed. All the fields become readonly. I cant figure out using the abobe JS how to incorporate to maintain the "Print" button visible, but does not print.

Any suggestions.

I have played adding the following to the script.
var a = this.getField("Print");
a.readonly = falce;

But it does not seem to work. Any suggestions???
K1K1
Registered: Aug 27 2010
Posts: 3
I have just realized that I had mispelled a.readonly=false;. I have corrected and tested again and the scrip works as I needed.
prander
Registered: Nov 6 2008
Posts: 44
What I was able to do with my "submit" button was run a Mouse Up "Run a J'script" that reads:

// Set fields to read-only
getField("Text1").readonly = true;
getField("Text2").readonly = true;
getField("Text3").readonly = true;

// Hide this button
event.target.display = display.hidden;

Then I have an "Execute a menu item>File>Save as..." action because I wanted the user to save/maintain their own copy.
Then I have a "Submit a form" action.

If you want to add a print button for the end user, I might make it separate from the submit button, I would definitely make it "Visible doesn't print" under the General tab in Button Properties. You can also do a Mouse Up "show/hide field" for just that button as well so that it completely disappears once it's clicked. I highly recommend that for forms that have both a submit and print button or else it's still there when the end user receives the pdf attachment.

Also, most importantly (this is in Pro 9), "Extend Features in Adobe Reader" (the Advance tab) for the whole document.

Hope this helps,
Page
adoacr
Registered: May 4 2011
Posts: 41
has anyone seen this issue where the textfield kinda turns readonl/inactive when I use:
this.getField("sField1").hidden = true;?
I also have a seperate question about this but thought id post it on here to see if anyone has any ideas?
this was for a pdf form I created with openoffice
adoacr
Registered: May 4 2011
Posts: 41
has anyone seen this issue where the textfield kinda turns readonl/inactive when I use:
this.getField("sField1").hidden = true;?
I also have a seperate question about this but thought id post it on here to see if anyone has any ideas?
this was for a pdf form I created with openoffice
maxwyss
Registered: Jul 25 2006
Posts: 255
Have a quick look at the Acrobat JavaScript documentation, and you will notice that

a) the hidden property should no longer be used (instead use the display property)

b) the field will be no longer visible, and therefore no longer accessible for the user


Hope this can help.

Max Wyss.