Copy link to clipboard
Copied
Hello,
I've been trying to find a code in which a text in Text Box A will trigger text in Text Box B. I am currently using a code that works when I type in the text on the form itself. However, when I have the pdf file run through a program that pre-populates text in Text Box A, it won't trigger text in Text Box B.
I am using this code:
if (event.value!=" ") this.getField("Text Box B").value= 20
I am not sure if there something I have to change because text box A has a prepopulated text?
Why all the added brackets and parentheses? It's not necessary.
Also, you're using the wrong operator in your if-statement. The comparison operator of JS is ==, not =. That's the assignment operator.
Use this code:
if (this.getField("Text Box A").valueAsString==" ") this.getField("Text Box B").value = "20";
Copy link to clipboard
Copied
You can place your code as a doc-level script, so that it executes when the file is first opened.
But then don't use event.value but this.getField("Text Box A").value, instead.
Copy link to clipboard
Copied
Hello,
My code looks like this and I also placed it as doc-level script, but the text is still not showing up for Text Box B
if (this.getField("Text Box A").value=" ") this.getField("Text Box B").value= "20"()()
{
}
Copy link to clipboard
Copied
Why all the added brackets and parentheses? It's not necessary.
Also, you're using the wrong operator in your if-statement. The comparison operator of JS is ==, not =. That's the assignment operator.
Use this code:
if (this.getField("Text Box A").valueAsString==" ") this.getField("Text Box B").value = "20";
Copy link to clipboard
Copied
Hello,
I used the code you provided, but nothing shows up in text box B after I run the pdf through the program...
Copy link to clipboard
Copied
Are you sure the value of the field is a single space, and not nothing, for example?
Also, check the JS console for error messages.
Copy link to clipboard
Copied
Yes, im sure, and i even tested it on 2 other fields with actual text, but nothing
and no error messages
Copy link to clipboard
Copied
Where did you place the code, exactly?
Can you share the file (either privately or via Google Drive, Dropbox, Adobe Cloud, etc.)?
Copy link to clipboard
Copied
Hello,
i'll share the file via google drive. I renamed some of the text boxes.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now