Copy link to clipboard
Copied
I'm trying to assign a value to a text field when they choose a radio button. It has worked before but now when I enter the Javascript in the Custom Calculation script of the text field, it disappears and remains blank. I don't know how to resolve it. This is the Javascript I tried to use
if(this.getField("Package").value == "Off") event.value = "";
if(this.getField("Package").value == "Package1") event.value = "400";
if(this.getField("Package").value == "Package2") event.value = "600";
if(this.getField("Package").value == "Package3") event.value = "700";
if(this.getField("Package").value == "Package4") event.value = "800";
if(this.getField("Package").value == "Package5") event.value = "500";
if(this.getField("Package").value == "Package6") event.value = "700";
if(this.getField("Package").value == "Package7") event.value = "800";
if(this.getField("Package").value == "Package8") event.value = "900"
Check the JavaScript console for errors by pressing Ctrl + J.
Also, it could be simplified to this:
// Set up an object to associate the possible field values with a corresponding number
var oVals = {
"Off" : "",
"Package1" : 400,
"Package2" : 600,
"Package3" : 700,
"Package4" : 800,
"Package5" : 500,
"Package6" : 700,
"Package7" : 800,
"Package8" : 900
};
// Set this field's value
event.value = oVals[getField("Package").valueAsString];
Copy link to clipboard
Copied
Check the JavaScript console for errors by pressing Ctrl + J.
Also, it could be simplified to this:
// Set up an object to associate the possible field values with a corresponding number
var oVals = {
"Off" : "",
"Package1" : 400,
"Package2" : 600,
"Package3" : 700,
"Package4" : 800,
"Package5" : 500,
"Package6" : 700,
"Package7" : 800,
"Package8" : 900
};
// Set this field's value
event.value = oVals[getField("Package").valueAsString];
Copy link to clipboard
Copied
Thanks I'll try this out.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now