Setting a field in a PDF Form using JavaScript

Hi There

I would like to set an existing PDF form field value depending on another form field value. E.g.
if the user who fills the form enters 20 in field A, then insert into field B the value 40 (2*A).

I would appreciate it, if someone has a short example.

FYI: I generate the PDF using QuickPDF and Delphi but this doesnt change anything in the answer I am looking for..

Thanks in advance!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this
var fieldA = this.getField("fieldA");
var fieldB = this.getField("fieldB");

fieldB.value = fieldA.value * 2;

Open in new window

skiaholicAuthor Commented:
thanks for your answer but I tested the JavaScript code in Adobe LiveCycle Designer (ALC) and it didn't worked and neither with
the Delphi Library QuickPDF.

But what worked with ALC was to address the field directly with it's name
and to get the value using .rawValue.. like

fieldB.rawValue = fieldA.rawValue * 2;

but this didn't work with Delphi QuickPDF..

Maybe anyone has an idea why?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
What does this mean that it doesn't work with Delphi QuickPDF?  I am unfamiliar with Delphi QuickPDF.. is that a PDF authoring tool sort of like ALC?  I'm guessing that when you try and use the javascript with Delphi QuickPDF the javascript is not working?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

skiaholicAuthor Commented:
Quick PDF is a library to modify and create PDF files and forms. The problem is, that I don't have access to their source code. Using adobe livecycle designer 8 the code I posted works.

That's why I am thinking that maybe there is a bug in quickPDF or they use different syntax, don't know..

Let's see if someone else has an idea otherwise I will accept my solution as the solution since it works with adobe livecycle designer..

Thank you!
Yeah, I'm assuming that the javascript version isn't the same.  As in my first example, that was for and older PDF done in Acrobat version 7.
skiaholicAuthor Commented:
It is only partially correct since it works with livecycle designer but not with the QuickPDF library in delphi.

That's also why I only gave grade B.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.