Square root calculation in a form

By: Tudor Oman | Asked: 09/24/2022
ForumsCategory: How-toSquare root calculation in a form
Tudor Oman asked 2 years ago

Hi is there a way of using a square root calculation in a form. I see there is a shortcode you can use for a view but how can I display the calculation in the form. eg

QTc calculator
(Number field 1)
(Number field 2)
Text - default text = (Number field 2)*0.04
Text field 2 - default text = (Number field 1)*0.04/[square_root number=[ID ofText field 1]]
0r
Text field 2 - default text = (Number field 1)*0.04/√((Number field 1)*0.04)

Any help would be appreciated. Thanks Tudor

4 Answers
Best Answer
Victor Font answered 2 years ago
Field calculations can use the jQuery.Math() library that includes a square root function: See this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt
Tudor Oman answered 2 years ago

Thanks - I had tried this but I am not sure if I am using it correctly. 
the formula I put into the text field for the calculation is this:

(Number field 1)*0.04/Math.SQRT((Number field 2)*0.04)
Tudor Oman answered 2 years ago

Thanks - I had tried this but I am not sure if I am using it correctly. 
the formula I put into the text field for the calculation is this:

(Number field 1)*0.04/Math.SQRT((Number field 2)*0.04)
Tudor Oman answered 2 years ago
Okay have it now the SQRT needs to be in lowercase Math.sqrt - works a treat. Thanks for the help Tudor

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right