Team:Calgary/VGSandbox

From 2012.igem.org

(Difference between revisions)
Line 3: Line 3:
 +
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)
-
<script language="JavaScript">
+
<FORM NAME="BMI" method=POST>
-
<!--
+
<TABLE border=1>
-
// 4-digit Chmod calculator
+
<TR>
-
// Based on code by Peter Crouch 2000. All rights reserved.
+
<TD><DIV ALIGN=CENTER>Your Weight (kg)</DIV></TD>
-
// Modified 2001 to 4-digit by William E. Landfair-Owens
+
<TD><DIV ALIGN=CENTER>Your Height (cm)</DIV></TD>
-
// http://welo.ikemail.com
+
<TD><DIV ALIGN=CENTER>Your BMI</DIV></TD>
-
// Visit http://javascriptkit.com for this script and more
+
<TD><DIV ALIGN=CENTER>My Comment</DIV></TD>
 +
</TR>
 +
 
 +
<TR>
 +
<TD><INPUT TYPE=TEXT NAME=weight  SIZE=10 onFocus="this.form.weight.value=''"></TD>
 +
<TD><INPUT TYPE=TEXT NAME=height  SIZE=10 onFocus="this.form.height.value=''"></TD>
 +
<TD><INPUT TYPE=TEXT NAME=bmi    SIZE=8 ></TD>
 +
<TD><INPUT TYPE=TEXT NAME=my_comment size=35></TD>
 +
</TABLE>
 +
 
 +
<P>
 +
<INPUT TYPE="button" VALUE="Let's see" onClick="computeform(this.form)">
 +
<INPUT TYPE="reset"  VALUE="Reset" onClick="ClearForm(this.form)">
 +
</FORM>
 +
 
 +
<HR>
 +
 
 +
 
 +
<B>Disclaimer</B>: This form is based on the calculation of
 +
<A HREF="http://phaster.com/unpretentious/bmi.html"><I>"Body Mass Index"</I></A>
 +
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.
 +
<p>This free script provided by
 +
<a href="http://javascriptkit.com">JavaScript
 +
Kit</a></p>
 +
<hr>
 +
 
 +
<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 calculator(user, number){
 
-
// Superuser
 
-
if (user == "superuser" && number == "4"){var box = eval("document.chmod.superuser4")}
 
-
if (user == "superuser" && number == "2"){var box = eval("document.chmod.superuser2")}
 
-
if (user == "superuser" && number == "1"){var box = eval("document.chmod.superuser1")}
 
-
// Owner
 
-
if (user == "owner" && number == "4"){var box = eval("document.chmod.owner4")}
 
-
if (user == "owner" && number == "2"){var box = eval("document.chmod.owner2")}
 
-
if (user == "owner" && number == "1"){var box = eval("document.chmod.owner1")}
 
-
// Group
 
-
if (user == "group" && number == "4"){var box = eval("document.chmod.group4")}
 
-
if (user == "group" && number == "2"){var box = eval("document.chmod.group2")}
 
-
if (user == "group" && number == "1"){var box = eval("document.chmod.group1")}
 
-
// Other
 
-
if (user == "other" && number == "4"){var box = eval("document.chmod.other4")}
 
-
if (user == "other" && number == "2"){var box = eval("document.chmod.other2")}
 
-
if (user == "other" && number == "1"){var box = eval("document.chmod.other1")}
 
-
if (box.checked == true){
 
-
if (user == "superuser"){
 
-
document.chmod.h_superuser.value += ("+number")
 
-
var a= (document.chmod.h_superuser.value)
 
-
var b= eval(a)
 
-
document.chmod.h_superuser.value=b
 
-
document.chmod.t_superuser.value=b
 
-
}if (user == "owner"){
 
-
document.chmod.h_owner.value += ("+number")
 
-
var a= (document.chmod.h_owner.value)
 
-
var b= eval(a)
 
-
document.chmod.h_owner.value=b
 
-
document.chmod.t_owner.value=b
 
-
}if (user == "group"){
 
-
document.chmod.h_group.value += ("+number")
 
-
var a= (document.chmod.h_group.value)
 
-
var b= eval(a)
 
-
document.chmod.h_group.value=b
 
-
document.chmod.t_group.value=b
 
-
}if (user == "other"){
 
-
document.chmod.h_other.value += ("+number")
 
-
var a= (document.chmod.h_other.value)
 
-
var b= eval(a)
 
-
document.chmod.h_other.value=b
 
-
document.chmod.t_other.value=b
 
}
}
 +
 +
function bmi(weight, height) {
 +
 +
          bmindx=weight/eval(height*height);
 +
          return bmindx;
}
}
-
if (box.checked == false){
 
-
if (user == "superuser"){
 
-
if (document.chmod.h_superuser.value == ""){
 
-
document.chmod.t_superuser.value=""
 
-
}else {
 
-
var a=(document.chmod.h_superuser.value);
 
-
b=a-(number);
 
-
c=eval(b);
 
-
document.chmod.h_superuser.value=c
 
-
document.chmod.t_superuser.value=c
 
-
}}if (user == "owner"){
 
-
if (document.chmod.h_owner.value == ""){
 
-
document.chmod.t_owner.value=""
 
-
}else {
 
-
var a=(document.chmod.h_owner.value);
 
-
b=a-(number);
 
-
c=eval(b);
 
-
document.chmod.h_owner.value=c
 
-
document.chmod.t_owner.value=c
 
-
}}if (user == "group"){
 
-
if (document.chmod.h_group.value == ""){
 
-
document.chmod.t_group.value=""
 
-
}else {
 
-
var a=(document.chmod.h_group.value);
 
-
b=a-(number);
 
-
c=eval(b);
 
-
document.chmod.h_group.value=c
 
-
document.chmod.t_group.value=c
 
-
}}if (user == "other"){
 
-
if (document.chmod.h_other.value == ""){
 
-
document.chmod.t_other.value=""
 
-
}else {
 
-
var a=(document.chmod.h_other.value);
 
-
b=a-(number);
 
-
c=eval(b);
 
-
document.chmod.h_other.value=c
 
-
document.chmod.t_other.value=c
 
-
}}
 
-
}}
 
-
// -->
 
-
</script>
 
-
<form name="chmod">
 
-
<input name="h_superuser" type="hidden"><input name="h_owner" type="hidden"><input name="h_group" type="hidden"><input name="h_other" type="hidden">
 
-
<table bgcolor="black" cellpadding="5" cellspacing="1">
 
-
<tr bgcolor="white">
 
-
<td colspan="6">
 
-
<center>
 
-
<font face="Verdana" size="3"><b>4-digit Chmod</b></font></center>
 
-
</td>
 
-
</tr>
 
-
<tr bgcolor="white" align="center">
 
-
<td colspan="2"><font face="Verdana" size="2"><b>Superuser</b></font></td>
 
-
<td><font face="Verdana" size="2"><b>Permission</b></font></td>
 
-
<td><font face="Verdana" size="2"><b>Owner</b></font></td>
 
-
<td><font face="Verdana" size="2"><b>Group</b></font></td>
 
-
<td><font face="Verdana" size="2"><b>Other</b></font></td>
 
-
</tr>
 
-
<tr bgcolor="white" align="center">
 
-
<td><font face="Verdana" size="2"><b>setuid</b></font></td>
 
-
<td><input type="checkbox" name="superuser4" value="4" onclick="calculator('superuser', 4)"></td>
 
-
<td><font face="Verdana" size="2"><b>Read</b></font></td>
 
-
<td><input type="checkbox" name="owner4" value="4" onclick="calculator('owner', 4)"></td>
 
-
<td><input type="checkbox" name="group4" value="4" onclick="calculator('group', 4)"></td>
 
-
<td><input type="checkbox" name="other4" value="4" onclick="calculator('other', 4)"></td>
 
-
</tr>
 
-
<tr bgcolor="white" align="center">
 
-
<td><font face="Verdana" size="2"><b>setgid</b></font></td>
 
-
<td><input type="checkbox" name="superuser2" value="2" onclick="calculator('superuser', 2)"></td>
 
-
<td><font face="Verdana" size="2"><b>Write</b></font></td>
 
-
<td><input type="checkbox" name="owner2" value="2" onclick="calculator('owner', 2)"></td>
 
-
<td><input type="checkbox" name="group2" value="2" onclick="calculator('group', 2)"></td>
 
-
<td><input type="checkbox" name="other2" value="2" onclick="calculator('other', 2)"></td>
 
-
</tr>
 
-
<tr bgcolor="white" align="center">
 
-
<td><font face="Verdana" size="2"><b>stickybit</b></font></td>
 
-
<td><input type="checkbox" name="superuser1" value="1" onclick="calculator('superuser', 1)"></td>
 
-
<td><font face="Verdana" size="2"><b>Execute</b></font></td>
 
-
<td><input type="checkbox" name="owner1" value="1" onclick="calculator('owner', 1)"></td>
 
-
<td><input type="checkbox" name="group1" value="1" onclick="calculator('group', 1)"></td>
 
-
<td><input type="checkbox" name="other1" value="1" onclick="calculator('other', 1)"></td>
 
-
</tr>
 
-
<tr bgcolor="white" align="center">
 
-
<td><font face="Verdana" size="2"><b>Value</b></font></td>
 
-
<td><input type="text" name="t_superuser" size="1"></td>
 
-
<td><b>+</b></td>
 
-
<td><input type="text" name="t_owner" size="1"></td>
 
-
<td><input type="text" name="t_group" size="1"></td>
 
-
<td><input type="text" name="t_other" size="1"></td>
 
-
</tr>
 
-
</table>
 
-
</form>
 
-
<p><font face="arial" size="1">This free script provided by</font><br>
 
-
<a href="http://javascriptkit.com"><font face="arial,helvetica" size="1">JavaScript Kit</font></a></p>
 
 +
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>

Revision as of 17:58, 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