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

Highlighting Trouble

pflores@sunflow...
Registered: Aug 21 2007
Posts: 37

I have a field where the scripts are written as follows (for highlight the field once they enter it and unhighlight when they leave:
enter=
DayPhone.border.edge.color.value = "0,0,255";
exit =
DayPhone.border.edge.color.value = "255,255,255";
 
This will work on some fields (copy & paste, change field name), but not all. Why?

My Product Information:
LiveCycle Designer, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
To create a function to highlight a field, to be called from multiple fields, use this method.

The following example uses a Document JavaScript function ChangeColor() to handle all highlighting events. Then, you would add a ChangeColor() call to each field you would like highlighting applied, for both the On Focus and On Blur events. This function toggles the color of the field, so it can be called for both events.

function ChangeColor() {
var myField = event.target;
if(event.name == "Focus") {
myField.fillColor = color.blue;
myField.borderColor = color.black;
}
else if (event.name == "Blur")
myField.fillColor = color.transparent;
}

To highlighting multiple fields using a for loop

Use a Document Level JavaScript function that will highlight any field that calls the function when the mouse cursor enters that field. Code can be added to all fields by running a script from the JavaScript console.

The first example defines the ChangeColor() function which will change the color of a field as the user’s cursor enters or leaves a field (the On Focus and On Blur events, respectively).

Select Tools > JavaScript > Document JavaScripts, and in the resulting dialog box enter a name and the ChangeColor() function shown in the above section,The following script can be run from the console to assign the ChangeColor() function .

// loop through all fields in document
for (var i = 0; i < this.numFields; i++) {
// set the ChangeColor function as the
// action for the field
var f =
this.getField(this.getNthFieldName(i));
f.setAction("OnFocus", "ChangeColor();");
f.setAction("OnBlur", "ChangeColor();");
}

The code will loop through all fields in the form and add the highlighting code to each field. For fields to which you don’t want the actions to apply (such as for a button field), double-click them with the object selection tool to get the Field Properties window; click the Action tab; and then delete the attached script.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.