Team:Calgary/VGSandbox

From 2012.igem.org

(Difference between revisions)
Line 1: Line 1:
<html>
<html>
-
<body>
 
Enter your weight in kilograms and your height in centimeters in the form below and press the "Let's see" button (Please read disclaimer below before using this form)
Enter your weight in kilograms and your height in centimeters in the form below and press the "Let's see" button (Please read disclaimer below before using this form)
Line 38: Line 37:
<hr>
<hr>
-
<script language="javascript" src="https://static.igem.org/mediawiki/2012/8/88/Html5GameTest.txt">Javascript not supported!</script>
+
<SCRIPT LANGUAGE="JAVASCRIPT">
 +
<!-- hide this script tag's contents from old browsers
 +
 
 +
//Body Mass calculator- by John Scott (johnscott03@yahoo.com)
 +
//Visit JavaScript Kit (http://javascriptkit.com) for script
 +
//Credit must stay intact for use
 +
 
 +
function ClearForm(form){
 +
 
 +
    form.weight.value = "";
 +
    form.height.value = "";
 +
    form.bmi.value = "";
 +
    form.my_comment.value = "";
 +
 
 +
}
 +
 
 +
function bmi(weight, height) {
 +
 
 +
          bmindx=weight/eval(height*height);
 +
          return bmindx;
 +
}
 +
 
 +
function checkform(form) {
 +
 
 +
      if (form.weight.value==null||form.weight.value.length==0 || form.height.value==null||form.height.value.length==0){
 +
            alert("\nPlease complete the form first");
 +
            return false;
 +
      }
 +
 
 +
      else if (parseFloat(form.height.value) <= 0||
 +
                parseFloat(form.height.value) >=500||
 +
                parseFloat(form.weight.value) <= 0||
 +
                parseFloat(form.weight.value) >=500){
 +
                alert("\nReally know what you're doing? \nPlease enter values again. \nWeight in kilos and \nheight in cm");
 +
                ClearForm(form);
 +
                return false;
 +
      }
 +
      return true;
 +
 
 +
}
 +
 
 +
function computeform(form) {
 +
 
 +
      if (checkform(form)) {
 +
 
 +
      yourbmi=Math.round(bmi(form.weight.value, form.height.value/100));
 +
      form.bmi.value=yourbmi;
 +
 
 +
      if (yourbmi >40) {
 +
          form.my_comment.value="You are grossly obese, consult your physician!";
 +
      }
 +
 
 +
      else if (yourbmi >30 && yourbmi <=40) {
 +
          form.my_comment.value="Umm... You are obese, want some liposuction?";
 +
      }
 +
 
 +
      else if (yourbmi >27 && yourbmi <=30) {
 +
          form.my_comment.value="You are very fat, do something before it's too late";
 +
      }
 +
 
 +
      else if (yourbmi >22 && yourbmi <=27) {
 +
          form.my_comment.value="You are fat, need dieting and exercise";
 +
      }
 +
 
 +
      else if (yourbmi >=21 && yourbmi <=22) {
 +
          form.my_comment.value="I envy you. Keep it up!!";
 +
      }
 +
 
 +
      else if (yourbmi >=18 && yourbmi <21) {
 +
          form.my_comment.value="You are thin, eat more.";
 +
      }
 +
 
 +
      else if (yourbmi >=16 && yourbmi <18) {
 +
          form.my_comment.value="You are starving. Go Find some food!";
 +
      }
 +
 
 +
      else if (yourbmi <16) {
 +
          form.my_comment.value="You're grossly undernourished, need hospitalization ";
 +
      }
 +
 
 +
      }
 +
      return;
 +
}
 +
// -- done hiding from old browsers -->
 +
</SCRIPT>
</body>
</body>
</html>
</html>

Revision as of 22:32, 16 May 2012

Enter your weight in kilograms and your height in centimeters in the form below and press the "Let's see" button (Please read disclaimer below before using this form)

Your Weight (kg)
Your Height (cm)
Your BMI
My Comment


Disclaimer: This form is based on the calculation of "Body Mass Index" and is only meant to be a demonstration of how Javascript(tm) could be used on a Web Page. Information it contains may not be accurate and is not designed or intended to serve as medical advice. I am not liable for any physical or psychological damages suffered as a result of using this script.

This free script provided by JavaScript Kit