Copy link to clipboard
Copied
I have a form with a number of fields set to use a custom calculation script. That script is below:
var ro = true;
var plan = Number(this.getField("Option1").value);
if (plan==100)
event.value = "Included";
else if (plan==125)
event.value = "Included";
else if (plan==150)
event.value = "Included";
else if (plan==200)
event.value = "Included";
else {
event.value = "";
ro = false;
}
event.target.readonly = ro;
So based on this the field in question is supposed to take a look at the field named "Option1" and if one of four (4) predetermined values are present ($100, $125, $150 or $200) the field should display "$0" and the field is set as read only.
If none of those four (4) predetermined values are present then the field should unlock to allow for manual data entry.
Everything works fine except that when I tab out of the field it deletes any data I've manually entered.
I am perplexed. Can anyone give any guidance here?
Thanks!
Copy link to clipboard
Copied
It would be much better to not use a calculation script and instead use a custom validation script for the dropdown that sets the value of the text field and controls its read-only property. Something like the following, which assumes there is a dropdown entry that's a single space to indicate no item is selected:
// Custom Validate script for dropdown
(function () {
// Get a reference to the text field
var f = getField("Text1"); // Replace with the actual name of the text field
// Control the value and readonly property of text field
if (event.value === " ") {
f.value = "";
f.readonly = false;
} else {
f.value = "Included";
f.readonly = true;
}
})();
Copy link to clipboard
Copied
Hi George.
Thanks for your response.
Just one thing. I don't have a drop-down.
The way the form works is there are four columns. Each column has approximately 70 fields. The top field of each column is where the "variable" is entered. If either 100, 125, 150 or 200 is entered the desired action is for each of the subordinate 69 fields display a desired value and switch to read-only.
If any value other than the four values I just listed are entered then all 69 subordinate fields switch to allowing manual entry and are no longer read-only.
All of this works fine.
The issue is that if I manually enter data the data is lost upon tabbing out of the field.
Thanks.
Copy link to clipboard
Copied
OK, for some reason I assumed you were using a dropdown. I would still use the same approach, using a custom validate script in the four Option fields. It should greatly improve the performance and simplify what you want to do. If you'd like help with the script, post again and include the names of the fields for rows 2-70.
The reason your manual entry is getting removed is because your existing calculate script sets the value to an empty string in the final "else" clause of your if statement.
Copy link to clipboard
Copied
Thanks George.
I've attached in image below of the field names. I've also included a bullet list below that.
Thanks.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now