Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2007-12-11 18:43:37

Grumlin3
Member
Registered: 2007-12-05
Posts: 0

Is it possible to have a button highlight required fields before printing?

How can I make a button in Adobe Acrobat Professional 7 to highlight all required fields before the form is printed out?


My Product Information:
Acrobat Pro 7 / Windows

Offline

 

#2 2007-12-12 09:20:55

pddesigner
Member

Registered: 2007-04-24
Posts: 55

Re: Is it possible to have a button highlight required fields before printing?

Highlighting required fields

Create two buttons in a document containing form fields. One button has the JavaScript mouse up action showRequired();
that will highlight all required fields, the other button has the following mouse up action restoreRequired(); that restores the fields to the appearance state they were in before the showRequired() function executed.

The script that follows is a document-level JavaScript that defines the functions called by the two buttons.

var oFieldNames = new Object(); // used to save the appearance of the fields
function showRequired() {
// Search through all fields for those that are set to required, excluding
// any button fields.
for ( var i=0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if ( (f.type != "button") && f.required) {
// Save appearance data in oFieldNames
oFieldNames[fname]={ strokeColor: f.strokeColor,
fillColor: f.fillColor};
// Assign a red boundary color, and fill color
f.strokeColor=color.red;
f.fillColor=app.runtimeHighlightColor;
}
}
}
// Now restore the fields.
function restoreRequired() {
if ( typeof oFieldNames == "object") {
for ( var o in oFieldNames ) {
var f = this.getField(o);
f.strokeColor=oFieldNames[o].strokeColor;
f.fillColor=oFieldNames[o].fillColor;
}
}
oFieldNames = new Object();
}

Offline

 

#3 2007-12-13 10:36:26

Grumlin3
Member
Registered: 2007-12-05
Posts: 0

Re: Is it possible to have a button highlight required fields before printing?

Thank you so much for your help, I greatly appreciate it. Unfortunately, I am not very familiar with Java Scripting where and how would I insert the names of the fields I want highlighted? Such as "Reason for Request"?

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

AcrobatUsers.com  >>  User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in