How calculate a square root?

I need calculate the square root in PDF format.
I tried the "Math.sqrt" and "sqrt" functions but they don´t work.
Thanks


chus portero


Voted Best Answer

Math.sqrt() should work. To display the square root of the value of the field myField, you add the following to the Calculate event of the field where you want to display it:

event.value = Math.sqrt(this.getField("myField").value) ;


However, it may be useful to validate the field value, in order to get valid and legal results:

if (!isNaN(this.getField("myField").value) && (this.getField("myField").value*1) >= 0) {
event.value = Math.sqrt(this.getField("myFild").value*1) ;
}


An alternative to Math.sqrt() is Math.pow(), where the simple code for the square root would look like.

event.value = Math.pow(this.getField("myField").value*1,0.5) ;

And that should do it.

Hope this can help.

Max Wyss.


By Max Wyss   


Please specify a reason: