• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Need help with calculations - BMI

Need help with calculations - BMI 11 years 11 months ago #23456

  • infotech
  • infotech's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Hello,

I am creating a form for a public health department for health appraisals. I was wondering if there was a way for the form to calculate BMI from a persons height and weight. Here is an example:

Height - 6 feet
Weight - 230 pounds

((230)/(72x72))x 703 = 31.19

I'm very novice and scripting and I'm not even sure this is possible. Any help would be greatly appreciated.
The administrator has disabled public write access.

Need help with calculations - BMI 11 years 11 months ago #23470

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
You can refer to the 'Calculation Form Example' form on our demo website, it provides a good example for your described scenario:

demo.rsjoomla.com/calculation-form-example
demo.rsjoomla.com/administrator
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Need help with calculations - BMI 11 years 11 months ago #23478

  • infotech
  • infotech's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Trust me I've tried this (for hours)

This is what I ended up with

function calculateText(){

var op1=document.getElementById('Height');

var op2=document.getElementById('Weight');

var result=document.getElementById('BMI');

if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;

if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;

result.value=0;

result.value=parseInt(result.value);

result.value=((parseInt(op2.value)/(parseInt(op1.value)*(parseInt(op1.value))*703;}


I then put onclick="calculateText();" in the attributes of a "calculate BMI" button and nothing happens when I click it. Very frustrating, I am not a coder.
The administrator has disabled public write access.

Need help with calculations - BMI 11 years 11 months ago #23483

  • infotech
  • infotech's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
I was successfully able to get this to work. I will post the script for anyone who would like to use it as a reference:

<script type="text/javascript">
function calculateText(){

var op1=document.getElementById('Height');

var op2=document.getElementById('Weight');

var result=document.getElementById('BMI');

if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;

if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;

result.value=0;

result.value=parseInt(result.value);

result.value=parseInt(op2.value*703)/parseInt(op1.value*op1.value);}
</script>

I learned a lot about javascript!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!