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

How to enter BSA calculation

Community Beginner ,
Mar 07, 2017 Mar 07, 2017

I need to calculate BSA which is:

       Sqrt((Ht*Wt) /3600)

   

I have tried entering in everything and cannot get it right      

TOPICS
Acrobat SDK and JavaScript
1.3K
Translate
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 1 Correct answer

Community Beginner , Mar 07, 2017 Mar 07, 2017

The fields I have are HT and WT

I copy and pasted the code into the BSA field and still does not calculate.


Is there anything else I can do?


Thank you so much

Translate
Community Expert ,
Mar 07, 2017 Mar 07, 2017

Let's say you have fields called Ht and Wt. Enter this code as the custom calculation script for the BSA field:

var ht = Number(this.getField("Ht").value);

var wt = Number(this.getField("Wt").value);

if (ht==0 || wt==0) event.value = "";

else event.value = Math.sqrt((ht*wt)/3600);

Translate
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 Beginner ,
Mar 07, 2017 Mar 07, 2017

The fields I have are HT and WT

I copy and pasted the code into the BSA field and still does not calculate.


Is there anything else I can do?


Thank you so much

Translate
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 ,
Mar 07, 2017 Mar 07, 2017

Did you adjust the field names in the code? Are there any error messages in the JS Console (Ctrl/Cmd+J) when you change the value of one of the fields?

Translate
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 Beginner ,
Mar 07, 2017 Mar 07, 2017

I do not get any error messages.

This is what I entered:

varWT= Number(this.getField(WT).value); 

if(HT==0||WT==0)event.value = ""; 

else event.value = Math.sqrt((HT*WT)/3600)

Translate
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 ,
Mar 07, 2017 Mar 07, 2017

I highly doubt there are no errors messages as I see at least three errors in that code...

Where's the definition of the HT variable?

Where's the space after var in the first line?

Where are the quotes around the field's name in the first line?

Translate
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 Beginner ,
Mar 07, 2017 Mar 07, 2017

So what I am wanting to do is create a universal form that has height and weight. Once the height and weight are entered, I would like it to populate the BSA.

one field box I named it: HT

second field box is: WT

and then I have a field box for BSA

I am not sure how to define the the variables when they will change each time a weight or height is changed

Sorry, I am completely new to this

Translate
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 ,
Mar 07, 2017 Mar 07, 2017

I understood that and the code I provided will do it. All you had to do was adjust the names of the fields in it, like this:

var ht = Number(this.getField("HT").value);

var wt = Number(this.getField("WT").value);

if (ht==0 || wt==0) event.value = "";

else event.value = Math.sqrt((ht*wt)/3600);

Don't change anything else!

Translate
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 Beginner ,
Mar 07, 2017 Mar 07, 2017
LATEST

THANK YOU! SO MUCH! That worked perfectly

Translate
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