Copy link to clipboard
Copied
Dropdown list1:
2 different doses of the same medication:
Dropdown list2:
3 different frequency of application of this medicine
I would like to have a script to calculate the possibilities in one place on a pdf form:
And the same for the dose2.
Thanks,
I would appreciate your help in this.
Thanks,
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 = "";}
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?
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,
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
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,
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.
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
Copy link to clipboard
Copied
That would work but He/She also need to use format or He/She will get really large number if for example divide 100/3.
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.
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)
Copy link to clipboard
Copied
So what exactly do you want? if it's 33.3 you want to show it as 33?
Copy link to clipboard
Copied
Dropdown list1:
2 different doses of the same medication:
Dropdown list2:
3 different frequency of application of this medicine
I would like to have a script to calculate the possibilities in one place on a pdf form:
And the same for the dose2.
Thanks,
Copy link to clipboard
Copied
Can you show us example how you have imagine this calculation pls?
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...
Copy link to clipboard
Copied
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
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 = "";}