Copy link to clipboard
Copied
Hello everyone! I have searched this forum for days and tried many things but cannot find a workable solution to my problem. My javascripting skills are novice at best.
I have created a numerical free text box "NumberValue" and a dropdown menu "TextChoices" with 5 text choices (ie Text1, Text2, Text3, Text4, Text5). IF the user selects Text1 AND the previous numerical box "NumberValue" is >12 THEN make the "NumberValue" = 12. IF the user selects Text1 AND the "NumberValue" is <12 THEN make "NumberValue" = the users input. IF the user selects any other text choice THEN "NumberValue" = the users input.
Any advice other than closing the program and walking away?
You could use a custom Validate script for the NumberValue field, something like this:
// Custom Validate script of a numeric text field
(function () {
// Get the value of the TextChoices field, as a string
var sTextChoices = getField("TextChoices").valueAsString;
// Alter this field's value if necessary
if (+event.value > 12 && sTextChoices === "Text1") {
event.value = 12;
}
})();
Copy link to clipboard
Copied
You could use a custom Validate script for the NumberValue field, something like this:
// Custom Validate script of a numeric text field
(function () {
// Get the value of the TextChoices field, as a string
var sTextChoices = getField("TextChoices").valueAsString;
// Alter this field's value if necessary
if (+event.value > 12 && sTextChoices === "Text1") {
event.value = 12;
}
})();
Copy link to clipboard
Copied
George,
YOU, sir, are amazing! Thank you! Your script opens up so many options. One followup question though. I've noticed upon testing that if I were to populate the numeric text field first THEN select the proper text choice from the dropdown, the numeric text field still maintains the user entered value. The script works great if the text choice was selected first then the numeric text field was populated.
Is there an option to have the numeric field update if the appropriate dropdown text choice is chosen after the numeric text field population?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now