Copy link to clipboard
Copied
When selecting a checkbox I want to export the data to a text box. I have this code.
Trigger: Mouse Up
Action: Run a JavaScript
var one = this.getField("Check Box2");
var two = this.getField("Text6");
{two.value=one.value}
When clicked it puts the export data from Check Box2 into Text6. However, if I want to change my selection, it will not allow the new export data to be exported into Text6 as it already has the data from the previous selection in it. Any help on the code to clear Text6 before a selection is made in Check Box2 would be much appreciated.
Copy link to clipboard
Copied
Is that code in the Mouse Up event of the "Check Box2" check box, or some other one?
Copy link to clipboard
Copied
I actually put the code in the custom calculation script of Text6, and it works. However, I have discovered another problem. If the Checkbox is off, I get the default value "Off" in Text6, Can I change this default value of "Off" to something else?
Copy link to clipboard
Copied
It was in the Mouse Up Trigger of the checkbox.
Copy link to clipboard
Copied
You cannot change the value that the check box is set to when it is unchecked. It is fixed at the string "Off". The Mouse Up script of the check box could be:
// Mouse Up script for check box
(function () {
// Get a reference to the text field
var f = getField("Text6");
// Populate the text field with a value depending on the state of this check box
if (event.target.value !== "Off") {
f.value = event.target.value; // Export value of check box
} else {
f.value = "Something else"; // replace with whatever you want to display when unchecked
}
})();
You original script might appear to work as a custom calculation script, but it's not correct.
[Edited to correct typo]
Copy link to clipboard
Copied
I copied and pasted your code in the checkbox, Mouse Up Trigger and I get this "SyntaxError: unterminated string literal 8:at line 9"
Copy link to clipboard
Copied
Change this line:
if (event.target.value !== "Off) {
To:
if (event.target.value !== "Off") {
Find more inspiration, events, and resources on the new Adobe Community
Explore Now