Copy link to clipboard
Copied
I am trying to figure out how to clear fields via javascript if a checkbox is triggered. Anyone have a script? What exactly is the JS term to clear fields?
Copy link to clipboard
Copied
this.resetForm(["Field1", "Field2", "Field3"]);
Copy link to clipboard
Copied
It depends whether you mean "set to blank" or "set to default value (which might not be blank)".
Case 1: set to empty string (or what is appropriate for non-text fields)
Case 2: resetForm indeed.
Copy link to clipboard
Copied
Thank you Test Screen Name,
So would the script look like this for case 1?
CASE 1:-
this.emptyString(["Field1", "Field2", "Field3"]);
Copy link to clipboard
Copied
No, that's not how you would clear the fields to an empty string instead of the default (case 1). There is no single call for that, you need to reset each one separately or in a loop.
Copy link to clipboard
Copied
"So would the script look like this for case 1? "
for (var i = 1; i < 4; i++) {
this.getField("Field" + i).value = "";
}
Copy link to clipboard
Copied
That's in case those are the actual field names. A more generic example is this:
var fields = ["Field1", "Field2", "Field3"]; // replace with actual field names
for (var i in fields) {
this.getField(fields[i]).value = "";
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now