Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- >
- Acrobat SDK
- >
- dropdown list calculation with independent values

Explorer
,

Aug 19, 2020

Copy link to clipboard

Copied

**Dropdown list1:**

2 different doses of the same medication:

- dose1
- dose2

**Dropdown list2:**

3 different frequency of application of this medicine

- every8hours (Q8h)
- every6hours (Q6h)
- every12hours (Q12h)

I would like to have a script to calculate the possibilities in one place on a pdf form:

- dose1 (Q8h): meaning dose1 would be divided by 3 times per day
- dose 1 (Q6h): meaning dose1 would be divided by 4 times per day
- dose 1 (Q12h): meaning dose1 would be divided by 2 times per day

And the same for the dose2.

Thanks,

I would appreciate your help in this.

Thanks,

Engaged

Give export value in dropdown1 dose1 100 and dose2 200, for dropdown2 give export value to Q6h 4, to Q8h 3, and to Q12h 2, also select "commit value immediately in both fields.

In your text box enter this script:

event.value = this.getField("Dropdown1").value/this.getField("Dropdown2").value;

if(event.value == "NaN"||event.value == "Infinity"){

event.value = "";}

TOPICS

Acrobat SDK and JavaScript,
PDF forms

Community Guidelines

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

Explorer
,

Aug 19, 2020

Copy link to clipboard

Copied

**Dropdown list1:**

2 different doses of the same medication:

- dose1
- dose2

**Dropdown list2:**

3 different frequency of application of this medicine

- every8hours (Q8h)
- every6hours (Q6h)
- every12hours (Q12h)

I would like to have a script to calculate the possibilities in one place on a pdf form:

- dose1 (Q8h): meaning dose1 would be divided by 3 times per day
- dose 1 (Q6h): meaning dose1 would be divided by 4 times per day
- dose 1 (Q12h): meaning dose1 would be divided by 2 times per day

And the same for the dose2.

Thanks,

I would appreciate your help in this.

Thanks,

Engaged

Give export value in dropdown1 dose1 100 and dose2 200, for dropdown2 give export value to Q6h 4, to Q8h 3, and to Q12h 2, also select "commit value immediately in both fields.

In your text box enter this script:

event.value = this.getField("Dropdown1").value/this.getField("Dropdown2").value;

if(event.value == "NaN"||event.value == "Infinity"){

event.value = "";}

TOPICS

Acrobat SDK and JavaScript,
PDF forms

Community Guidelines

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

Wissam5FBB

Aug 19, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/td-p/11372824
15
Replies
15

Engaged
,

Aug 22, 2020

Copy link to clipboard

Copied

can you be more specific. what are you actually try to calculate?

dose1 (Q8h): meaning dose1 would be divided by 3 times per day - how you want to calculate this?

Community Guidelines

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

Reply

Loading...

Asim123

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378631#M2958
Explorer
,

Aug 22, 2020

Copy link to clipboard

Copied

dose 1 is 100 mg/kg/d

dose 2 is 200 mg/kg/d

This is the first drop list

second drop list has the options of the possible frequencies:

Q8h, Q6h, Q12h

and as you said: Q8h means I have to divide the dose by 3 (and by 4 for Q6h, and by 2 for Q12h)

Thanks,

Community Guidelines

Reply

Loading...

Wissam5FBB

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378672#M2960
Adobe Community Professional
,

Aug 22, 2020

Copy link to clipboard

Copied

HI,

This would appear to be a simple sum, or am I missing something:

if dose 1 is selected ( set export vaue to 100 ) and Q8h is selected (set export value to 3).

then the result is just do a divide in the JavaScript, and add any additional information there.

Hope this helps

Malcolm

Community Guidelines

Reply

Loading...

BarlaeDC

Aug 22, 2020
1
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378686#M2962
Explorer
,

Aug 22, 2020

Copy link to clipboard

Copied

Yes Malcolm it is as you said but I wanted to know how the script should be written.

(NB: I am not an expert 🙂 )

Thanks,

Community Guidelines

Reply

Loading...

Wissam5FBB

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378716#M2964
Enthusiast
,

Aug 22, 2020

Copy link to clipboard

Copied

You don't need a script just use simplified field notation and write like this: Dropdown1/Dropdown2

Unless you also want to show "200 mg/kg/d" in results? then you would need script.

Community Guidelines

Reply

Loading...

Nesa Nurani

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378728#M2966
Adobe Community Professional
,

Aug 22, 2020

Copy link to clipboard

Copied

Hi,

As above, would work but if you want the extra then you could use a calculation script ( I would only do this if your form does not have many fields as it can have a usability impact)

```
var doseCalc = this.getField("Dose").value / this.getField("Freq").value;
event.value = doseCalc + " mg/kg/d";
```

Hope that helps

Malcolm

Community Guidelines

Reply

Loading...

BarlaeDC

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378729#M2967
Enthusiast
,

Aug 22, 2020

Copy link to clipboard

Copied

so use simplified field notation and add this in "Format->Custom format->Custom format script:

AFNumber_Format(2, 0, 0, 0, " mg/kg/d", false);

number 2 represent decimals so set to whatever number you want.

Community Guidelines

Reply

Loading...

Nesa Nurani

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378744#M2969
Explorer
,

Aug 22, 2020

Copy link to clipboard

Copied

This would not work because I can't divide by the frequency itself, this is why i though it will need a script with condition:

if from droplist1 the dose is 100, and from droplist2 the frequency is 8 then the result is: 33.3 mg

(100/3)

(droplist1:

-dose 1 is 100 mg/kg/d

-dose 2 is 200 mg/kg/d

droplist2 has 3 frequencies:

-Q8h,

-Q6h,

-Q12h)

Community Guidelines

Reply

Loading...

Wissam5FBB

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378754#M2971
Engaged
,

Aug 22, 2020

Copy link to clipboard

Copied

So what exactly do you want? if it's 33.3 you want to show it as 33?

Community Guidelines

Reply

Loading...

Asim123

Aug 22, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11378761#M2973
Explorer
,

Aug 27, 2020

Copy link to clipboard

Copied

**Dropdown list1:**

2 different doses of the same medication:

- dose1
- dose2

**Dropdown list2:**

3 different frequency of application of this medicine

- every8hours (Q8h)
- every6hours (Q6h)
- every12hours (Q12h)

I would like to have a script to calculate the possibilities in one place on a pdf form:

- dose1 (Q8h): meaning dose1 would be divided by 3 times per day
- dose 1 (Q6h): meaning dose1 would be divided by 4 times per day
- dose 1 (Q12h): meaning dose1 would be divided by 2 times per day

And the same for the dose2.

Thanks,

Community Guidelines

Reply

Loading...

Wissam5FBB

Aug 27, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11390894#M2975
Engaged
,

Aug 27, 2020

Copy link to clipboard

Copied

Can you show us example how you have imagine this calculation pls?

Community Guidelines

Reply

Loading...

Asim123

Aug 27, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11390931#M2977
Explorer
,

Aug 27, 2020

Copy link to clipboard

Copied

If I put it in a sentence it would be:

if drop1=dose1 and drop2=Q8h

then event value= dose1/ 3

and

if drop1=dose2 and drop2=Q12h

then event value= dose2/ 2

etc...

Community Guidelines

Reply

Loading...

Wissam5FBB

Aug 27, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11391361#M2979
Engaged
,

Aug 27, 2020

Copy link to clipboard

Copied

Community Guidelines

Reply

Loading...

Asim123

Aug 27, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11391469#M2981
Explorer
,

Aug 27, 2020

Copy link to clipboard

Copied

Thanks Asim for trying to help me.

If I can get the script for the following sentence, regardless what they are representing as numbers or doses this will fix my problem:

if drop1=choice A and drop2=Q8h

then event value= choice A/ 3

and

if drop1=B and drop2=Q12h

then event value= B/ 2

Community Guidelines

Reply

Loading...

Wissam5FBB

Aug 27, 2020
0
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11392295#M2983
Correct answer by
Asim123
LATEST

Engaged
,

Aug 27, 2020

Copy link to clipboard

Copied

Give export value in dropdown1 dose1 100 and dose2 200, for dropdown2 give export value to Q6h 4, to Q8h 3, and to Q12h 2, also select "commit value immediately in both fields.

In your text box enter this script:

event.value = this.getField("Dropdown1").value/this.getField("Dropdown2").value;

if(event.value == "NaN"||event.value == "Infinity"){

event.value = "";}

Community Guidelines

Reply

Loading...

Asim123

Aug 27, 2020
1
/t5/acrobat-sdk/dropdown-list-calculation-with-independent-values/m-p/11392408#M2985
Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português

Copyright © 2020 Adobe. All rights reserved.