Expand my Community achievements bar.

SOLVED

Need Help: Check box auto fill value in text field and text field calculation

Avatar

Level 2

Noob to this site.

So i currently have a form fillable which I'm wondering if certain actions are possible. I'm fairly new to real technical aspects of livecycle so spare with me if you can.

I have a series of 4 check boxes with values assign to each. Below the 4 check boxes i have an additonal 4 text fields that atleast one of the fields pertain to any of the 4 checkbox selections possible.

ok, here we go so spare with me:

     Is it possible to tie the 4 check boxes to the text field below, meaning when you click any of the 4 check boxes, the value included next to the check box will auto fill in the text field below pertaining to the 4 selections possible?

     Second question: how can i modify the text fields to auto calculate numerical values with the 4th text field ending in the calculation result?

example below

Accrual per Year
Check Box
100
120
144
160


Text Fields
Comments
Current Vacation Balance

Minus Accrual for One Year
--->  This is where i want the above check box to auto fill when selected above
( = )
i want this field to subtract 1st filed and 2nd field givign me the total

Hours Eligible to convert:

50% of balance above


i want this field to take the above total field and divide it by 2

Can anyone help please. Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

If I work on the basis that the four objects in the table are called:

  1. currentBalance
  2. accrual
  3. balance
  4. eligibleHours

Then if you go to the 3rd field (balance) and have the following in the calculate event (JavaScript):

this.rawValue = currentBalance.rawValue - accrual.rawValue;

In the 4th field (eligibleHours) and have the following in the calculate event (JavaScript):

this.rawValue = balance.rawValue / 2;

Niall

View solution in original post

26 Replies

Avatar

Level 10

Hi,

Is the user allowed to select any number of the Accrual per Year checkboxes? Or can they only select one?

If it is intended that they can only select one, then I would change the table to a series of four radio buttons. This is a visual clue to the user that they can only select one choice.

Yes, it is very feasible to create script to do the number cruncing. But it would be best to sort out the checkbox/radio button issue first.

Niall

Avatar

Level 2

well the user is required to select which of the Accrual per year that applies to him/her so yes user suppose to only select one.

So you recommend for me to change the check boxes to radial buttons instead?

Avatar

Level 10

That's correct. Radio buttons are set up to be mutually exclusive and the shape lets the user know this.

  • Drag a radio button onto the form.
  • Duplicate it three times.
  • You should have four radio buttons inside one radio button exclusion group. Have a look at the hierarchy.

There is an example here that how to set up the radio buttons and the script in the click event of the radio button exclusion group:

https://acrobat.com/#d=qE1IszHcL6589QQYB7ceGg.

There are more examples here: http://www.assuredynamics.com/index.php/code-solutions/.

Niall

Avatar

Level 2

checking the links now

I'm very new to the scripts piece so lets take a look lol.

Avatar

Level 2

okay, i got the radio buttons figured out and i applied the script so the radio button value appears on the numeric field.

now from the second table on my first post; how do i execute the follow action: Current Balance - (subtract) Accrual for one year field to give me a total in the ( =) field. Then have the 4th field divide total (=) field by 2 and give me a grand total in the 4th field.

Avatar

Correct answer by
Level 10

If I work on the basis that the four objects in the table are called:

  1. currentBalance
  2. accrual
  3. balance
  4. eligibleHours

Then if you go to the 3rd field (balance) and have the following in the calculate event (JavaScript):

this.rawValue = currentBalance.rawValue - accrual.rawValue;

In the 4th field (eligibleHours) and have the following in the calculate event (JavaScript):

this.rawValue = balance.rawValue / 2;

Niall

Avatar

Level 2

ok, let me give it a try.

If it wasn't for you i would be lost today. Thanks a mill Niall

Avatar

Level 10

Just to warn you, this will work if the four objects are in the same container, eg subform.

If the objects are in different rows or subforms, then you will need to amend the sample script to give a relative reference from the object with the script to the objects referenced in the script.

See a summary of SMO Expressions here: http://assure.ly/kUP02y.

Niall

Avatar

Level 2

well the scripts work wonderful but somehow i can't get the first script to take the first field Current Balance and subtract it by Accrual to give me a total.

what is doing is only taking the Accrual and subtracting it by its own.

I did replace the verbage CurrentBalance and Accrual by highlighting them and holding control key then clicking on their designated fields so it can be properly identified.

Think i am doing something wrong or is do i have to add something after     ;  in the script code

Avatar

Level 10

If you are using JavaScript you will need to include a ".rawValue" after each object's name.

Can you post the script?

Niall

Avatar

Level 2

just saw your warning post,

the fields are not currently in sub form, interestig enought the script worked for the bottom 3 fields leaving the first top one not working, i will put them in sub form to see if it works.

Avatar

Level 10

It's not that the object have to be specifically in a subform, the warning was more to ensure your relative references were sufficient if the objects were in different subforms.

Niall

;-(

Avatar

Level 2

okay the 4 fields are in subform now but the script you provided me to add on field three is still not picking up the first field

Avatar

Level 10

We'll get there.

When previewing the form in Acrobat (and Designer) open the JavaScript Console (Control+J). When you interact with the form if there is a problem it should show up there. This will help debug it.

Javascript Console.png

Niall

Avatar

Level 2

im getting this message when i open in acrobat Capture.JPG

Avatar

Level 10

That's it. The script I gave you is JavaScript, but the language in that object's event is set to FormCalc. You just need to go in and change the language in the Script Editor.

Also looking at the screenshot, you can set up Display Patterns for the numericfields. See the Object > Field palette. Something like num{z,zzz,zz9} would do.

Niall

Avatar

Level 10

Also, with the form open in Designer and you are in the Script Editor, there is a Check Syntax button to the right of the event dropdown. If you go to your script and click this, it should highlight errors in red.

Niall

Avatar

Level 2

actually i had screwed up the script for the last field and that is why it is showing a crazy number but i fix it and its giving me the appropriate 2 or 3 digit number.

i did apply the script in calculate event do you suggest that i should change it?

Avatar

Level 2

this is where i'm applying the scripts

Capture2.JPG

if you notice i highligted the field that i'm having trouble with so that way you can see the script

Avatar

Level 2

Success i got it working

i guess i had repeatedly kept adding a 1 by accident in between (field) and .rawvalue