Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Introducing math operators

From: Acrobat X: Creating Forms

Video: Introducing math operators

Acrobat provides some built-in calculation help. I can do the Sum, Product, Average, Minimum and Maximum. When we get to Difference you'll see, well there is sort of a punch line to this. Let me set up the field so they'll do the math. Sum1 and sum2 are going to contain the data that's entered, sum3 is going to contain the total. So in the Text Field Properties, I go to the Calculate tab and I tell sum3 that it's going to be the sum of sum1 and sum2. And click Ok.

Introducing math operators

Acrobat provides some built-in calculation help. I can do the Sum, Product, Average, Minimum and Maximum. When we get to Difference you'll see, well there is sort of a punch line to this. Let me set up the field so they'll do the math. Sum1 and sum2 are going to contain the data that's entered, sum3 is going to contain the total. So in the Text Field Properties, I go to the Calculate tab and I tell sum3 that it's going to be the sum of sum1 and sum2. And click Ok.

And you can already see a bit of the math taking place back here. I am going to finish most of these out and then we'll go back and check the results. Notice that I can talk to a different field without having to hit Close and exit this dialog. I can click on prod3 and now that's a field whose options I am changing. So that's going to multiply prod1 times prod2, so I tell prod3, it's going to be the product of, and I scroll down my list, prod1 and prod2, click OK. You can see it's starting to happen back there.

For the Average, the Value is the average of avg1, avg2, and avg3, click OK. Be thinking, how you might use these math operations in the kind of forms you think you are going to have to build. Minimum and maximum sort of an odd one because you can see everything in front of you and you could pick the minimum and maximum, but there may come a time when this is beneficial for you. I am going to start with minimum and I am going to tell it to examine these fields, minmax1, 2, 3, and 4.

When I close, we'll take a look at the result. Sum is working, Product is working, aren't you glad you learn your multiplication tables, and then for Average, your average is 9, 10, and 11. The Minimum and Maximum, yes it's obvious to us that 29 is the minimum, but again, this may come in handy for you later. Let's do the maximum. I am just going to modify this so that it's now the maximum of, and I still have the same fields picked, so I am ahead with that. Click Close, switch to my Hand Tool, there we go.

I don't know if you noticed, when we are looking at that list of potential math operations, but, there is nothing for subtraction, there is nothing for difference. So this is a bitter shortfall in the built-in math operations. It means that you have to solve this by writing JavaScript. Don't run-away. Don't be scared. Yes, JavaScript is a programming language. I'm not a programmer, but I can do simple JavaScript. And you'll find a number of resources. When you find existing forms that have JavaScript in them, if you think you want to pursue it, I would encourage you to sort of deconstruct them and see how they are built.

And you can copy little snippets and educate yourself that way. So here for my Custom calculation script, ooh, this is so impressive, I click Edit. Here's what I need to do. I need to tell Acrobat, okay I want you to look in the field diff1, store that value, then look in the field diff2 and store that value, and then address this field diff3 and subtract diff2 from diff1. So this is a bit long-winded, but you store the contents of each field and a variable. So I will say variable a=this.getField, odd little phrase, it means in this document, go get this field essentially, diff1, and in case, the name of the field in quotes and parenthesis, and then finish off the line with Semicolon.

In the next line, I tell it to take a look at diff2, so variable b equals this, typing is very important in JavaScript, again open paren and quotes, that's going to be diff2, and again, another Semicolon. And then I tell it to take a look at diff3 and perform an operation in diff3. So variable c=this.getField, yet again, diff3 another Semicolon, and then here comes the math, the c.value, meaning the value of the field that we're identifying as variable c equals open parenthesis, it's going to be the a.value, again this is not a typing class, minus the b.value.

Just to kind of revisit this, yet this is kind of wordy, but when you break it down, it's kind of rational. Hey Acrobat, find out what's in diff1 stored in variable A. Find out what's in diff2, stored in variable B, assign a variable to diff3 just so we can talk to it, and then that c.value is going to be the a.value minus the b.value. So let's see if our programming works. If you've typed something wrong, if you missed to look somehow, you'll get a little error message here, and then it's up to you to go back and sort of thresh it out.

But I got lucky. I had no error messages. When I switch back to my Hand Tool, look it's done the math. Let's make sure that we know it works. We will put something in there that allows us to do math in our heads, and it works, there you go. So if you followed along with me, you've just written your first JavaScript. Isn't that exciting? So those are the simple math operations built into Acrobat and a little taste of JavaScript.

Show transcript

This video is part of

Image for Acrobat X: Creating Forms
Acrobat X: Creating Forms

38 video lessons · 15578 viewers

Claudia McCue
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Acrobat X: Creating Forms.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.