Copy link to clipboard
Copied
Hi
I am preparing an adobe form and have some text fields, radio buttons and check boxes that change fill color at different events. I have all the JavaScripts for this working all right.
Now, I want to add an action button to reset the form at "Mouse Up" event. I got the action button to reset all the text fields, radio buttons and check boxes using the "Reset a form" at "Mouse Up" event. However, the fill colors of text fields, radio buttons and check boxes does not go back to transparent when clicking on the reset form action button.
For example, I have a check box (lets call it CheckBox1). When the check box is selected it runs two JavaScripts, one that changes the fill color of the check box itself and one that changes the fill color of a text field that goes with the check box (lets call it TextField1). The two JavaScripts for CheckBox1 are these:
this.getField("CheckBox1").fillColor = event.target.value == "Off" ? color.transparent : color.yellow;
this.getField("TextField1").fillColor = event.target.value == "Off" ? color.transparent : color.yellow;
How come, when I click the action button for resetting the form, it only clears the check box but does not change the fill colors back to transparent?
Can I add a JavaScript to the reset action button that changes the fill colors, of all the fields (text fields, radio buttons and check boxes), to transparent when the reset action button is clicked?
Thank you.
Copy link to clipboard
Copied
You must not use the "Reset form" action, you must use the "Run a JavaScript" action with this script:
this.resetForm();
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
oFld.fillColor = color.transparent;
}
PDF Acrobatic, InDesigner & Photoshoptographer
Copy link to clipboard
Copied
Just add a line to restore its color (green in this sample):
this.resetForm();
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
oFld.fillColor = color.transparent;
}
event.target.fillColor = color.green;
PDF Acrobatic, InDesigner & Photoshoptographer
Copy link to clipboard
Copied
Or with a custom color:
this.resetForm();
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
oFld.fillColor = color.transparent;
}
event.target.fillColor = ["RGB", 255/255, 255/255, 204/255]; // light yellow
PDF Acrobatic, InDesigner & Photoshoptographer
Copy link to clipboard
Copied
You must not use the "Reset form" action, you must use the "Run a JavaScript" action with this script:
this.resetForm();
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
oFld.fillColor = color.transparent;
}
PDF Acrobatic, InDesigner & Photoshoptographer
Copy link to clipboard
Copied
Thank you, this works perfectly.
However, now the fill color of the action button itself also changes to transparent. Anyway I can keep the fill color of the action button?
Copy link to clipboard
Copied
Just add a line to restore its color (green in this sample):
this.resetForm();
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
oFld.fillColor = color.transparent;
}
event.target.fillColor = color.green;
PDF Acrobatic, InDesigner & Photoshoptographer
Copy link to clipboard
Copied
Or with a custom color:
this.resetForm();
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
oFld.fillColor = color.transparent;
}
event.target.fillColor = ["RGB", 255/255, 255/255, 204/255]; // light yellow
PDF Acrobatic, InDesigner & Photoshoptographer

