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);
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
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?
I do not get any error messages.
This is what I entered:
if(HT==0||WT==0)event.value = "";
else event.value = Math.sqrt((HT*WT)/3600)
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?
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
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!
THANK YOU! SO MUCH! That worked perfectly