Copy link to clipboard
Copied
Hi,
I have two questions;
1. How to make if another cell filled with text then another cell is equal to 1.
2. How to make if another cell not blank then another cell is equal to not blank + 1.
Thank you
Copy link to clipboard
Copied
Let's say you have fields "Text1" and "Text2".
1, You want to make "Text2" value 1 if "Text1" is not empty, as 'Validate' script of "Text1" use this:
if(event.value != "")this.getField("Text2").value = 1;
If you wish to make "Text2" back to empty if "Text1" is empty, then use this instead:
this.getField("Text2").value = event.value == "" ? "" : 1;
2. I don't fully understand what you wish with 'equal to not blank' +1?, can you explain please? Do you want to set it to 1 (same as first question) or add +1 to the value already in the field?
Copy link to clipboard
Copied
Hi Nesa thank you for your reply. As I am very newbie I need to revise my question little bit.
1. I have a text field A and text field B.
If text field B is blank, text field A will be blank, else 1.
if (event.value != "") this.getField("Text2").value = 1; correct?
2. I have another text field C and text field D, and text field C will be blank if text field D is blank else Text field A +1
Copy link to clipboard
Copied
You can read about writing "if" statments here:
https://acrobatusers.com/tutorials/conditional-execution/
You're first if is incomplete. When writing a conditional, all conditions must be accounted for.
if (event.value != "")
this.getField("Text2").value = 1;
else
this.getField("Text2").value = "";
You also said the text fields were "Text A " and "Text B" then used "Text2". And also didn't mention where this code is placed. Assuming that "Text2" is really "Text A" since that's that value being set, then this code should be in the Validation event for "Text B". That is, according to your description.
Copy link to clipboard
Copied
1. Use the second code I gave you but use it in text field "B" as Validation script:
this.getField("A").value = event.value == "" ? "" : 1;
Make sure field name is correct.
2. Use this at text field "D":
var a = this.getField("A");
if(event.value == "")
this.getField("C").value = "";
else
a.value += 1;