• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Script check needed

New Here ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Hi all,

 

I would like to have a check on the script for my checklist. It has 16 categories and for each category there are 4 options: 0 , 1 , 2 , 3 (for all the options the value is alike, so 0 =value 0, 1 =value 1, etc.)

 

at the bottom of each option there's a field: subtotal

 now I've added the following code to those fields: 

 

event.value=(this.getField("Top_0").value+this.getField("Vest_0").value +this.getField("Broek_0").value +this.getField("Panty_0").value +this.getField("Schoenen_0").value +this.getField("Haar_0").value +this.getField("Makeup_0").value +this.getField("Bril_0").value +this.getField("Oorbellen_0").value +this.getField("Ketting_0").value +this.getField("Sjaal_0").value +this.getField("Armbanden_0").value +this.getField("Ringen_0").value +this.getField("Nagellak_0").value +this.getField("Riem_0").value +this.getField("Tas_0").value)

 

event.value=(this.getField("Top_1").value+this.getField("Vest_1").value +this.getField("Broek_1").value +this.getField("Panty_1").value +this.getField("Schoenen_1").value +this.getField("Haar_1").value +this.getField("Makeup_1").value +this.getField("Bril_1").value +this.getField("Oorbellen_1").value +this.getField("Ketting_1").value +this.getField("Sjaal_1").value +this.getField("Armbanden_1").value +this.getField("Ringen_1").value +this.getField("Nagellak_1").value +this.getField("Riem_1").value +this.getField("Tas_1").value)

 

event.value=(this.getField("Top_2").value+this.getField("Vest_2").value +this.getField("Broek_2").value +this.getField("Panty_2").value +this.getField("Schoenen_2").value +this.getField("Haar_2").value +this.getField("Makeup_2").value +this.getField("Bril_2").value +this.getField("Oorbellen_2").value +this.getField("Ketting_2").value +this.getField("Sjaal_2").value +this.getField("Armbanden_2").value +this.getField("Ringen_2").value +this.getField("Nagellak_2").value +this.getField("Riem_2").value +this.getField("Tas_2").value)

 

event.value=(this.getField("Top_3").value+this.getField("Vest_3").value +this.getField("Broek_3").value +this.getField("Panty_3").value +this.getField("Schoenen_3").value +this.getField("Haar_3").value +this.getField("Makeup_3").value +this.getField("Bril_3").value +this.getField("Oorbellen_3").value +this.getField("Ketting_3").value +this.getField("Sjaal_3").value +this.getField("Armbanden_3").value +this.getField("Ringen_3").value +this.getField("Nagellak_3").value +this.getField("Riem_3").value +this.getField("Tas_3").value)

 

 

for the total field I used the (2nd) option: Value is the sum(+)

 

now when selecting the options, the total field is calculating the values correctly, only in the subtotalfields there's no value visible, so it looks like it isn't calculating. 

Can you help me with this? Is it something in the code?

TOPICS
Acrobat SDK and JavaScript

Views

210

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Enthusiast , Sep 14, 2020 Sep 14, 2020

In column 0 you want all buttons to have value 0, in column 1 all buttons have value 1...etc?

so for example if you select all buttons in column 1 result will be 16, if you select all buttons in column 3 result will be 32 and total would be 48, you want it  like that?

Likes

Translate

Translate
Community Expert , Sep 14, 2020 Sep 14, 2020

Try this OUTFIT_CHECKLIST_radiobuttons origineel1 and see if it works for you.

Likes

Translate

Translate
Community Expert ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

For the subtotal fields you can also use the (1st) option.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Hi Bernd,

 

what do you mean with the 1st option?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

For the calculation: Value is the sum(+)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

No that doesn't work. Then it calculates all the options from all the 4 vertical columns and in each subtotal field it gives the same value. Then even in the total field there comes a whole different value thats incorrect. 

image.jpg

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Can you share the form?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

I've added the file to my message

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Did you check Field calculation order? If that doesn't help,share your file here.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

I've shared the file 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Check the Javascript console for errors.

 

There are no fields with the name "Top_0", "Vest_0", and so on.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Yes that's exactly it. Those names belong to the radiobuttons and for that adobe didn't create a field(name) 

that's why I can't use the 1st option

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

The field names are "Top", "Vest", and so on.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Hi,

 

As they are radio buttons you can use the isBoxChecked(index) function to check if it is checked,  So you should be able to do something like :

 

var topChecked = this.getField("Top").isBoxChecked(0);

if ( topChecked) {

// Add to total

}

 

Then just change the index to when you are counting a differnt row. ( just remember it is a 0 based index)

 

Regards

 

Malcolm

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Hi Malcolm, 

Where do I add the value of the boxes and how does the formula look when I add two (or more) fields?

 

Kind regards,
Stefanie

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Hi,

 

The code would look something like :

var Top = this.getField("Top");
var Vest = this.getField("Vest");
var Broek = this.getField("Broek"); 

var tempTotal = 0;
var amountToAdd = 1;
var indexToCheck = 0;

if ( Top.isBoxChecked(indexToCheck)){
tempTotal += amountToAdd;
}
if ( Vest.isBoxChecked(indexToCheck)){
tempTotal += amountToAdd;
}
if ( Broek.isBoxChecked(indexToCheck)){
tempTotal += amountToAdd;
}

event.value = tempTotal;

 

As each calculation uses the same fields you could move your calculation to a docment level javascript which would look something like :

[ to add document JavaScript, just search for "Document JavaScript" in the tools]

 

function calculateColumn ( amountToAdd, indexOfField){
var Top = this.getField("Top");
var Vest = this.getField("Vest");
var Broek = this.getField("Broek"); 

var tempTotal = 0;

if ( Top.isBoxChecked(indexOfField)){
tempTotal += amountToAdd;
}
if ( Vest.isBoxChecked(indexOfField)){
tempTotal += amountToAdd;
}
if ( Broek.isBoxChecked(indexOfField)){
tempTotal += amountToAdd;
}

return amountToAdd;
}

 

And then call it from each calculation like so:

// The first parameter is how much the count should go up by
// The second is which column you are wanting to count.
event.value = calculateColumn ( 1, 0);

 

Let us know if there are any problems.

 

Regards

 

Malcolm

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

I've tried the code but despitely it doesn't work

Could there be anything in settings that's not correct?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

In your form the command 

  this.getField("Top").value 

will give you following values:


Off

Top_0

Top_1

Top_2

Top_3

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

In column 0 you want all buttons to have value 0, in column 1 all buttons have value 1...etc?

so for example if you select all buttons in column 1 result will be 16, if you select all buttons in column 3 result will be 32 and total would be 48, you want it  like that?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Yes exactly!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Try this OUTFIT_CHECKLIST_radiobuttons origineel1 and see if it works for you.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Wauw Nesa,

 

It works! Fantastic!

What did you do to get it like this?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

You didn't have correct values in your radio buttons, so I changed all of them and writed new scripts for "Nummer" fields.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Ooh like that. Didn't know I could adjust that. Were did you change it?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

@NesaNurani:  The file works great when I download it to my computer and even when I move it from downloads to my documents and give it another name. Only when I upload the file to my mailing program, it doesn't work anymore. Do you know what the reason for this could be?

Also, when I open the file on my (I)phone, it doesn't work either...

 

Would be great if you could help me out on this. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

What app does you use on the phone?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines