Valiant
06-18-2007, 05:34 PM
Hi, this is my very first Javascript. I'm writing this for use in a hospital that I work in. I apologise for posting the whole page. However, I feel that in order for you to help me spot the mistake, you would need to look at the whole picture.
When the script is executed, nothing happens. Could someone please point to me where I went wrong? I'm very new to this. I've been trying everything I could for the past week. Please help me out. Thank you.
<html>
<head>
<title>Lipoc ATP Calculator</title>
<script type="text/javascript">
<!-- Begin
function calculate(form)
{
var age = form.age.value;
var chol = form.chol.value;
var hdl = form.hdl.selectedIndex;
var tsbp = form.tsbp.value;
var usbp = form.usbp.value;
var agept, smokept, cholpt, hdlpt, tsbpt, usbpt
var total, risk
// Check gender
if (form.gender[0].checked) {
var gender = "male"
} else {
if (form.gender[1].checked) {
var gender = "female"
} else {
alert("Please select your gender.");
return false
}
}
// Check age
if (!checkNum(age)) {
alert("Please enter your age.");
form.age.select();
form.age.focus();
return false
}
if ((age < 20) || (age > 79))
{
if (!confirm("This calculator is only for patients from 20 to 79 years old.")) {
form.age.select();
form.age.focus();
return false
}
}
// Check smoker
if (form.smoker[0].checked)
{
var smoker = "yes"
}
else
{
if (form.smoker[1].checked)
{
var smoker = "no"
}
else
{
alert("Does the patient smoke?");
return false
}
}
// Check cholesterols
if (!checkNum(chol))
{
alert("Please enter the patient's total cholesterol.")
form.chol.focus();
form.chol.select();
return false
}
if (hdl < 2)
{
alert("Please select a HDL cholesterol range.");
form.hdl.focus();
return false
}
// Check blood pressures
if (!checkNum(tsbp)) {
alert("Please enter the patient's treated systolic blood pressure.");
form.tsbp.focus();
form.tsbp.select();
return false
}
if (!checkNum(usbp)) {
alert("Please enter the patient's untreated systolic blood pressure.");
form.usbp.focus();
form.usbp.select();
return false
}
// Points Allocation
// Gender Points
if (gender == "female")
{
if ((age >= 75) && (age < 80)) {agept = 16;}
if ((age >= 70) && (age < 75)) {agept = 14;}
if ((age >= 65) && (age < 70)) {agept = 12;}
if ((age >= 60) && (age < 65)) {agept = 10;}
if ((age >= 55) && (age < 60)) {agept = 8;}
if ((age >= 50) && (age < 55)) {agept = 6;}
if ((age >= 45) && (age < 50)) {agept = 3;}
if ((age >= 40) && (age < 45)) {agept = 0;}
if ((age >= 35) && (age < 40)) {agept = -3;}
if ((age >= 20) && (age < 35)) {agept = -7;}
}
if (gender == "male")
{
if (age > 74 && age < 80) {agept = 13;}
if (age > 69 && age < 75) {agept = 12;}
if (age > 64 && age < 70) {agept = 11;}
if (age > 59 && age < 65) {agept = 10;}
if (age > 54 && age < 60) {agept = 8;}
if (age > 49 && age < 55) {agept = 6;}
if (age > 44 && age < 50) {agept = 3;}
if (age > 39 && age < 45) {agept = 0;}
if (age > 34 && age < 40) {agept = -4;}
if (age > 19 && age < 35) {agept = -9;}
}
form.agept.value = agept;
// Smoker Points
if (smoke == "yes")
{
if ((age >= 70) && (age < 80)) {smokerpt = 1;}
if ((age >= 60) && (age < 70)) {smokerpt = 2;}
if ((age >= 50) && (age < 60)) {smokerpt = 4;}
if ((age >= 40) && (age < 50)) {smokerpt = 7;}
if ((age >= 20) && (age < 40)) {smokerpt = 9;}
}
else {smokerpt = 0;}
form.smokerpt.value = smokerpt;
// Total Cholesterol Points
if (chol > 4 && chol < 5.2)
{
if ((age >= 60) && (age < 80)) {cholpt = 1;}
if ((age >= 50) && (age < 60)) {cholpt = 2;}
if ((age >= 40) && (age < 50)) {cholpt = 3;}
if ((age >= 20) && (age < 40)) {cholpt = 4;}
}
if (chol > 5.1 && chol < 6.2)
{
if ((age >= 70) && (age < 80)) {cholpt = 1;}
if ((age >= 60) && (age < 70)) {cholpt = 2;}
if ((age >= 50) && (age < 60))
{
if (gender == "female") {cholpt = 4;}
if (gender == "male") {cholpt = 3;}
}
if ((age >= 40) && (age < 50))
{
if (gender == "female") {cholpt = 6;}
if (gender == "male") {cholpt = 5;}
}
if ((age >= 20) && (age < 40))
{
if (gender == "female") {cholpt = 8;}
if (gender == "male") {cholpt = 7;}
}
}
if (chol > 6.1 && chol < 7.2)
{
if ((age >= 70) && (age < 80)) {cholpt = 2;}
if ((age >= 60) && (age < 70))
{
if (gender == "female") {cholpt = 3;}
if (gender == "male") {cholpt = 2;}
}
if ((age >= 50) && (age < 60))
{
if (gender == "female") {cholpt = 5;}
if (gender == "male") {cholpt = 4;}
}
if ((age >= 40) && (age < 50))
{
if (gender == "female") {cholpt = 8;}
if (gender == "male") {cholpt = 6;}
}
if ((age >= 20) && (age < 40))
{
if (gender == "female") {cholpt = 11;}
if (gender == "male") {cholpt = 9;}
}
if (chol > 7.2)
{
if ((age >= 70) && (age < 80)) {cholpt = 2;}
if ((age >= 60) && (age < 70)) {cholpt = 4;}
{
if (gender == "female") {cholpt = 4;}
if (gender == "male") {cholpt = 3;}
}
if ((age >= 50) && (age < 60)) {cholpt = 7;}
{
if (gender == "female") {cholpt = 7;}
if (gender == "male") {cholpt = 5;}
}
if ((age >= 40) && (age < 50)) {cholpt = 10;}
{
if (gender == "female") {cholpt = 10;}
if (gender == "male") {cholpt = 8;}
}
if ((age >= 20) && (age < 40)) {cholpt = 13;}
{
if (gender == "female") {cholpt = 13;}
if (gender == "male") {cholpt = 11;}
}
}
form.cholpt.value = cholpt;
// Treated Systolic BP Points
if ((tsbp > 40) && (tsbp < 120)) {tsbpt = 0;}
if ((tsbp >= 120) && (tsbp < 130))
{
if (gender == "female") {tsbpt = 3;}
if (gender == "male") {tsbpt = 1;}
}
if ((tsbp >= 130) && (tsbp < 140))
{
if (gender == "female") {tsbpt = 4;}
if (gender == "male") {tsbpt = 2;}
}
if ((tsbp >= 140) && (tsbp < 160))
{
if (gender == "female") {tsbpt = 5;}
if (gender == "male") {tsbpt = 2;}
}
if ((tsbp >= 160))
{
if (gender == "female") {tsbpt = 6;}
if (gender == "male") {tsbpt = 3;}
}
form.tsbpt.value = tsbpt;
// Untreated Systolic BP Points
if ((usbp > 40) && (usbp < 120)) {usbpt = 0;}
if ((usbp >= 120) && (usbp < 130))
{
if (gender == "female") {usbpt = 1;}
if (gender == "male") {usbpt = 0;}
}
if ((usbp >= 139) && (usbp < 140))
{
if (gender == "female") {usbpt = 2;}
if (gender == "male") {usbpt = 1;}
}
if ((usbp >= 149) && (usbp < 160))
{
if (gender == "female") {usbpt = 3;}
if (gender == "male") {usbpt = 1;}
}
if (usbp > 159)
{
if (gender == "female") {usbpt = 4;}
if (gender == "male") {usbpt = 2;}
}
form.usbpt.value = usbpt;
// Calculate total points
total = agept + smokept + cholpt + hdlpt + tsbpt + usbpt;
form.total.value = total;
// Estimation of 10-Year Coronary Heart Disease Risk
if (gender == "female")
if (total == 5)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 6)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 7)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 8)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 9)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 10)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 11)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "3";}
}
if (total == 12)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "3";}
}
if (total == 13)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "3";}
if (race == "indian") {risk = "4";}
}
if (total == 14)
{
if (race == "chinese") {risk = "2";}
if (race == "malay") {risk = "4";}
if (race == "indian") {risk = "6";}
}
if (total == 15)
{
if (race == "chinese") {risk = "3";}
if (race == "malay") {risk = "5";}
if (race == "indian") {risk = "7";}
}
if (total == 16)
{
if (race == "chinese") {risk = "3";}
if (race == "malay") {risk = "6";}
if (race == "indian") {risk = "10";}
}
if (total == 17)
{
if (race == "chinese") {risk = "4";}
if (race == "malay") {risk = "8";}
if (race == "indian") {risk = "12";}
}
if (total == 18)
{
if (race == "chinese") {risk = "5";}
if (race == "malay") {risk = "10";}
if (race == "indian") {risk = "16";}
}
if (total == 19)
{
if (race == "chinese") {risk = "7";}
if (race == "malay") {risk = "13";}
if (race == "indian") {risk = "20";}
}
if (total == 20)
{
if (race == "chinese") {risk = "9";}
if (race == "malay") {risk = "16";}
if (race == "indian") {risk = "> 20";}
}
if (total == 21)
{
if (race == "chinese") {risk = "12";}
if (race == "malay") {risk = "20";}
if (race == "indian") {risk = "> 20";}
}
if (total == 22)
{
if (race == "chinese") {risk = "15";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
if (total == 23)
{
if (race == "chinese") {risk = "19";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
if (total >= 24)
{
if (race == "chinese") {risk = "> 20";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
}
if (gender == "male")
if (total == -1)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 0)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 1)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 2)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 3)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 4)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 5)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "3";}
}
if (total == 6)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "3";}
}
if (total == 7)
{
if (race == "chinese") {risk = "2";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "4";}
}
if (total == 8)
{
if (race == "chinese") {risk = "2";}
if (race == "malay") {risk = "3";}
if (race == "indian") {risk = "5";}
}
if (total == 9)
{
if (race == "chinese") {risk = "3";}
if (race == "malay") {risk = "4";}
if (race == "indian") {risk = "7";}
}
if (total == 10)
{
if (race == "chinese") {risk = "4";}
if (race == "malay") {risk = "5;}
if (race == "indian") {risk = "9";}
}
if (total == 11)
{
if (race == "chinese") {risk = "5";}
if (race == "malay") {risk = "6";}
if (race == "indian") {risk = "11";}
}
if (total == 12)
{
if (race == "chinese") {risk = "6";}
if (race == "malay") {risk = "8";}
if (race == "indian") {risk = "14";}
}
if (total == 13)
{
if (race == "chinese") {risk = "8";}
if (race == "malay") {risk = "11";}
if (race == "indian") {risk = "18";}
}
if (total == 14)
{
if (race == "chinese") {risk = "11";}
if (race == "malay") {risk = "13";}
if (race == "indian") {risk = "> 20";}
}
if (total == 15)
{
if (race == "chinese") {risk = "13";}
if (race == "malay") {risk = "17";}
if (race == "indian") {risk = "> 20";}
}
if (total == 16)
{
if (race == "chinese") {risk = "17";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
if (total >= 17)
{
if (race == "chinese") {risk = "> 20";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
}
}
// End -->
</script>
</head>
<body>
<center>
<form name="calculator" method=post>
<table cellpadding="3px">
<tr><td colspan="3" align="center">
<p><b>Lipoc ATP Calculator</b></p>
</td>
</tr>
<tr><td style="background-color:#D4DBEE;" colspan="2" align="center"><b>Parameters</b></td>
<td style="background-color:#EED4E8;" align="center"><b>Points</b></td>
</tr>
<tr><td align="right" style="background-color:#E5ECFF;">Gender: </td>
<td align="left" style="background-color:#E5ECFF;">
<input type="radio" value="male" name="gender"> Male
<input type="radio" value="female" name="gender"> Female
</td>
<td align="right" style="background-color:#FFD86B;">
</td>
</tr>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>Age: </td>
<td align="left">
<input type="text" name="age" size="10" value=""> years (20 to 79)
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="agept">
</td>
</tr>
<tr align="right" style="background-color:#E5ECFF;"><td>Race: </td>
<td align="left">
<input type="radio" value="chinese" name="race">Chinese</option>
<input type="radio" value="indian" name="race">Indian</option>
<input type="radio" value="malay" name="race">Malay</option>
</select>
</td>
<td align="right" style="background-color:#FFD86B;">
</td>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>Smoker: </td>
<td align="left">
<input type="radio" value="yes" name="smoker">Yes</option>
<input type="radio" value="no" name="smoker">No</option>
</select>
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="smokerpt">
</td>
</tr>
<tr align="right" style="background-color:#E5ECFF;"><td>Total Cholesterol: </td>
<td align="left">
<input type="text" name="chol" size="10" value=""> mmol/L
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="cholpt">
</td>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>HDL Cholesterol: </td>
<td align="left">
<select size="1" name="hdl">
<option value="">-------------------</option>
<option value="-1">>= 1.6 (60)</option>
<option value="0">1.3-1.5 (50-59)</option>
<option value="1">1.0-1.2 (40-49)</option>
<option value="2">< 1.0 (40)</option>
</select> mmol/L (mg/dL)
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="hdlpt">
</td>
</tr>
<tr align="right" style="background-color:#E5ECFF;"><td>Treated Systolic BP: </td>
<td align="left">
<input type="text" name="tsbp" size="10" value=""> mmHg
</td>
<td align="right" style="background-color:#FFD86B;">
<input type=text value="" size="2" maxlength="2" name="tsbpt">
</td>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>Untreated Systolic BP: </td>
<td align="left">
<input type="text" name="usbp" size="10" value=""> mmHg
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="usbpt">
</td>
</tr>
<tr align="center" style="background-color:#FFE5F9;"><td colspan="2">
<input type="button" value="Calculate" onClick="calculate(this.form);">
<input type="reset" size="14" value="Clear Form">
</td>
<td align="right" style="background-color:#FFD86B;">
<b>Total: <input type=text value="" size="2" maxlength="2" name="total"></b>
</td>
</tr>
<tr align="right" style="background-color:#FFD86B;;"><td colspan="3">
<p><b>Estimation of 10 year risk of coronary heart disease:</b>
<input type="text" value="" size="3" maxlength="3" name="risk"> %
</p>
</table>
</form>
</center>
</body>
</html>
When the script is executed, nothing happens. Could someone please point to me where I went wrong? I'm very new to this. I've been trying everything I could for the past week. Please help me out. Thank you.
<html>
<head>
<title>Lipoc ATP Calculator</title>
<script type="text/javascript">
<!-- Begin
function calculate(form)
{
var age = form.age.value;
var chol = form.chol.value;
var hdl = form.hdl.selectedIndex;
var tsbp = form.tsbp.value;
var usbp = form.usbp.value;
var agept, smokept, cholpt, hdlpt, tsbpt, usbpt
var total, risk
// Check gender
if (form.gender[0].checked) {
var gender = "male"
} else {
if (form.gender[1].checked) {
var gender = "female"
} else {
alert("Please select your gender.");
return false
}
}
// Check age
if (!checkNum(age)) {
alert("Please enter your age.");
form.age.select();
form.age.focus();
return false
}
if ((age < 20) || (age > 79))
{
if (!confirm("This calculator is only for patients from 20 to 79 years old.")) {
form.age.select();
form.age.focus();
return false
}
}
// Check smoker
if (form.smoker[0].checked)
{
var smoker = "yes"
}
else
{
if (form.smoker[1].checked)
{
var smoker = "no"
}
else
{
alert("Does the patient smoke?");
return false
}
}
// Check cholesterols
if (!checkNum(chol))
{
alert("Please enter the patient's total cholesterol.")
form.chol.focus();
form.chol.select();
return false
}
if (hdl < 2)
{
alert("Please select a HDL cholesterol range.");
form.hdl.focus();
return false
}
// Check blood pressures
if (!checkNum(tsbp)) {
alert("Please enter the patient's treated systolic blood pressure.");
form.tsbp.focus();
form.tsbp.select();
return false
}
if (!checkNum(usbp)) {
alert("Please enter the patient's untreated systolic blood pressure.");
form.usbp.focus();
form.usbp.select();
return false
}
// Points Allocation
// Gender Points
if (gender == "female")
{
if ((age >= 75) && (age < 80)) {agept = 16;}
if ((age >= 70) && (age < 75)) {agept = 14;}
if ((age >= 65) && (age < 70)) {agept = 12;}
if ((age >= 60) && (age < 65)) {agept = 10;}
if ((age >= 55) && (age < 60)) {agept = 8;}
if ((age >= 50) && (age < 55)) {agept = 6;}
if ((age >= 45) && (age < 50)) {agept = 3;}
if ((age >= 40) && (age < 45)) {agept = 0;}
if ((age >= 35) && (age < 40)) {agept = -3;}
if ((age >= 20) && (age < 35)) {agept = -7;}
}
if (gender == "male")
{
if (age > 74 && age < 80) {agept = 13;}
if (age > 69 && age < 75) {agept = 12;}
if (age > 64 && age < 70) {agept = 11;}
if (age > 59 && age < 65) {agept = 10;}
if (age > 54 && age < 60) {agept = 8;}
if (age > 49 && age < 55) {agept = 6;}
if (age > 44 && age < 50) {agept = 3;}
if (age > 39 && age < 45) {agept = 0;}
if (age > 34 && age < 40) {agept = -4;}
if (age > 19 && age < 35) {agept = -9;}
}
form.agept.value = agept;
// Smoker Points
if (smoke == "yes")
{
if ((age >= 70) && (age < 80)) {smokerpt = 1;}
if ((age >= 60) && (age < 70)) {smokerpt = 2;}
if ((age >= 50) && (age < 60)) {smokerpt = 4;}
if ((age >= 40) && (age < 50)) {smokerpt = 7;}
if ((age >= 20) && (age < 40)) {smokerpt = 9;}
}
else {smokerpt = 0;}
form.smokerpt.value = smokerpt;
// Total Cholesterol Points
if (chol > 4 && chol < 5.2)
{
if ((age >= 60) && (age < 80)) {cholpt = 1;}
if ((age >= 50) && (age < 60)) {cholpt = 2;}
if ((age >= 40) && (age < 50)) {cholpt = 3;}
if ((age >= 20) && (age < 40)) {cholpt = 4;}
}
if (chol > 5.1 && chol < 6.2)
{
if ((age >= 70) && (age < 80)) {cholpt = 1;}
if ((age >= 60) && (age < 70)) {cholpt = 2;}
if ((age >= 50) && (age < 60))
{
if (gender == "female") {cholpt = 4;}
if (gender == "male") {cholpt = 3;}
}
if ((age >= 40) && (age < 50))
{
if (gender == "female") {cholpt = 6;}
if (gender == "male") {cholpt = 5;}
}
if ((age >= 20) && (age < 40))
{
if (gender == "female") {cholpt = 8;}
if (gender == "male") {cholpt = 7;}
}
}
if (chol > 6.1 && chol < 7.2)
{
if ((age >= 70) && (age < 80)) {cholpt = 2;}
if ((age >= 60) && (age < 70))
{
if (gender == "female") {cholpt = 3;}
if (gender == "male") {cholpt = 2;}
}
if ((age >= 50) && (age < 60))
{
if (gender == "female") {cholpt = 5;}
if (gender == "male") {cholpt = 4;}
}
if ((age >= 40) && (age < 50))
{
if (gender == "female") {cholpt = 8;}
if (gender == "male") {cholpt = 6;}
}
if ((age >= 20) && (age < 40))
{
if (gender == "female") {cholpt = 11;}
if (gender == "male") {cholpt = 9;}
}
if (chol > 7.2)
{
if ((age >= 70) && (age < 80)) {cholpt = 2;}
if ((age >= 60) && (age < 70)) {cholpt = 4;}
{
if (gender == "female") {cholpt = 4;}
if (gender == "male") {cholpt = 3;}
}
if ((age >= 50) && (age < 60)) {cholpt = 7;}
{
if (gender == "female") {cholpt = 7;}
if (gender == "male") {cholpt = 5;}
}
if ((age >= 40) && (age < 50)) {cholpt = 10;}
{
if (gender == "female") {cholpt = 10;}
if (gender == "male") {cholpt = 8;}
}
if ((age >= 20) && (age < 40)) {cholpt = 13;}
{
if (gender == "female") {cholpt = 13;}
if (gender == "male") {cholpt = 11;}
}
}
form.cholpt.value = cholpt;
// Treated Systolic BP Points
if ((tsbp > 40) && (tsbp < 120)) {tsbpt = 0;}
if ((tsbp >= 120) && (tsbp < 130))
{
if (gender == "female") {tsbpt = 3;}
if (gender == "male") {tsbpt = 1;}
}
if ((tsbp >= 130) && (tsbp < 140))
{
if (gender == "female") {tsbpt = 4;}
if (gender == "male") {tsbpt = 2;}
}
if ((tsbp >= 140) && (tsbp < 160))
{
if (gender == "female") {tsbpt = 5;}
if (gender == "male") {tsbpt = 2;}
}
if ((tsbp >= 160))
{
if (gender == "female") {tsbpt = 6;}
if (gender == "male") {tsbpt = 3;}
}
form.tsbpt.value = tsbpt;
// Untreated Systolic BP Points
if ((usbp > 40) && (usbp < 120)) {usbpt = 0;}
if ((usbp >= 120) && (usbp < 130))
{
if (gender == "female") {usbpt = 1;}
if (gender == "male") {usbpt = 0;}
}
if ((usbp >= 139) && (usbp < 140))
{
if (gender == "female") {usbpt = 2;}
if (gender == "male") {usbpt = 1;}
}
if ((usbp >= 149) && (usbp < 160))
{
if (gender == "female") {usbpt = 3;}
if (gender == "male") {usbpt = 1;}
}
if (usbp > 159)
{
if (gender == "female") {usbpt = 4;}
if (gender == "male") {usbpt = 2;}
}
form.usbpt.value = usbpt;
// Calculate total points
total = agept + smokept + cholpt + hdlpt + tsbpt + usbpt;
form.total.value = total;
// Estimation of 10-Year Coronary Heart Disease Risk
if (gender == "female")
if (total == 5)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 6)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 7)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 8)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 9)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 10)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 11)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "3";}
}
if (total == 12)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "3";}
}
if (total == 13)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "3";}
if (race == "indian") {risk = "4";}
}
if (total == 14)
{
if (race == "chinese") {risk = "2";}
if (race == "malay") {risk = "4";}
if (race == "indian") {risk = "6";}
}
if (total == 15)
{
if (race == "chinese") {risk = "3";}
if (race == "malay") {risk = "5";}
if (race == "indian") {risk = "7";}
}
if (total == 16)
{
if (race == "chinese") {risk = "3";}
if (race == "malay") {risk = "6";}
if (race == "indian") {risk = "10";}
}
if (total == 17)
{
if (race == "chinese") {risk = "4";}
if (race == "malay") {risk = "8";}
if (race == "indian") {risk = "12";}
}
if (total == 18)
{
if (race == "chinese") {risk = "5";}
if (race == "malay") {risk = "10";}
if (race == "indian") {risk = "16";}
}
if (total == 19)
{
if (race == "chinese") {risk = "7";}
if (race == "malay") {risk = "13";}
if (race == "indian") {risk = "20";}
}
if (total == 20)
{
if (race == "chinese") {risk = "9";}
if (race == "malay") {risk = "16";}
if (race == "indian") {risk = "> 20";}
}
if (total == 21)
{
if (race == "chinese") {risk = "12";}
if (race == "malay") {risk = "20";}
if (race == "indian") {risk = "> 20";}
}
if (total == 22)
{
if (race == "chinese") {risk = "15";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
if (total == 23)
{
if (race == "chinese") {risk = "19";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
if (total >= 24)
{
if (race == "chinese") {risk = "> 20";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
}
if (gender == "male")
if (total == -1)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 0)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "< 1";}
if (race == "indian") {risk = "1";}
}
if (total == 1)
{
if (race == "chinese") {risk = "< 1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 2)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "1";}
}
if (total == 3)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 4)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "2";}
}
if (total == 5)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "1";}
if (race == "indian") {risk = "3";}
}
if (total == 6)
{
if (race == "chinese") {risk = "1";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "3";}
}
if (total == 7)
{
if (race == "chinese") {risk = "2";}
if (race == "malay") {risk = "2";}
if (race == "indian") {risk = "4";}
}
if (total == 8)
{
if (race == "chinese") {risk = "2";}
if (race == "malay") {risk = "3";}
if (race == "indian") {risk = "5";}
}
if (total == 9)
{
if (race == "chinese") {risk = "3";}
if (race == "malay") {risk = "4";}
if (race == "indian") {risk = "7";}
}
if (total == 10)
{
if (race == "chinese") {risk = "4";}
if (race == "malay") {risk = "5;}
if (race == "indian") {risk = "9";}
}
if (total == 11)
{
if (race == "chinese") {risk = "5";}
if (race == "malay") {risk = "6";}
if (race == "indian") {risk = "11";}
}
if (total == 12)
{
if (race == "chinese") {risk = "6";}
if (race == "malay") {risk = "8";}
if (race == "indian") {risk = "14";}
}
if (total == 13)
{
if (race == "chinese") {risk = "8";}
if (race == "malay") {risk = "11";}
if (race == "indian") {risk = "18";}
}
if (total == 14)
{
if (race == "chinese") {risk = "11";}
if (race == "malay") {risk = "13";}
if (race == "indian") {risk = "> 20";}
}
if (total == 15)
{
if (race == "chinese") {risk = "13";}
if (race == "malay") {risk = "17";}
if (race == "indian") {risk = "> 20";}
}
if (total == 16)
{
if (race == "chinese") {risk = "17";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
if (total >= 17)
{
if (race == "chinese") {risk = "> 20";}
if (race == "malay") {risk = "> 20";}
if (race == "indian") {risk = "> 20";}
}
}
}
// End -->
</script>
</head>
<body>
<center>
<form name="calculator" method=post>
<table cellpadding="3px">
<tr><td colspan="3" align="center">
<p><b>Lipoc ATP Calculator</b></p>
</td>
</tr>
<tr><td style="background-color:#D4DBEE;" colspan="2" align="center"><b>Parameters</b></td>
<td style="background-color:#EED4E8;" align="center"><b>Points</b></td>
</tr>
<tr><td align="right" style="background-color:#E5ECFF;">Gender: </td>
<td align="left" style="background-color:#E5ECFF;">
<input type="radio" value="male" name="gender"> Male
<input type="radio" value="female" name="gender"> Female
</td>
<td align="right" style="background-color:#FFD86B;">
</td>
</tr>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>Age: </td>
<td align="left">
<input type="text" name="age" size="10" value=""> years (20 to 79)
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="agept">
</td>
</tr>
<tr align="right" style="background-color:#E5ECFF;"><td>Race: </td>
<td align="left">
<input type="radio" value="chinese" name="race">Chinese</option>
<input type="radio" value="indian" name="race">Indian</option>
<input type="radio" value="malay" name="race">Malay</option>
</select>
</td>
<td align="right" style="background-color:#FFD86B;">
</td>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>Smoker: </td>
<td align="left">
<input type="radio" value="yes" name="smoker">Yes</option>
<input type="radio" value="no" name="smoker">No</option>
</select>
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="smokerpt">
</td>
</tr>
<tr align="right" style="background-color:#E5ECFF;"><td>Total Cholesterol: </td>
<td align="left">
<input type="text" name="chol" size="10" value=""> mmol/L
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="cholpt">
</td>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>HDL Cholesterol: </td>
<td align="left">
<select size="1" name="hdl">
<option value="">-------------------</option>
<option value="-1">>= 1.6 (60)</option>
<option value="0">1.3-1.5 (50-59)</option>
<option value="1">1.0-1.2 (40-49)</option>
<option value="2">< 1.0 (40)</option>
</select> mmol/L (mg/dL)
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="hdlpt">
</td>
</tr>
<tr align="right" style="background-color:#E5ECFF;"><td>Treated Systolic BP: </td>
<td align="left">
<input type="text" name="tsbp" size="10" value=""> mmHg
</td>
<td align="right" style="background-color:#FFD86B;">
<input type=text value="" size="2" maxlength="2" name="tsbpt">
</td>
</tr>
<tr align="right" style="background-color:#FFE5F9;"><td>Untreated Systolic BP: </td>
<td align="left">
<input type="text" name="usbp" size="10" value=""> mmHg
</td>
<td align="right" style="background-color:#FFD86B;">
<input type="text" value="" size="2" maxlength="2" name="usbpt">
</td>
</tr>
<tr align="center" style="background-color:#FFE5F9;"><td colspan="2">
<input type="button" value="Calculate" onClick="calculate(this.form);">
<input type="reset" size="14" value="Clear Form">
</td>
<td align="right" style="background-color:#FFD86B;">
<b>Total: <input type=text value="" size="2" maxlength="2" name="total"></b>
</td>
</tr>
<tr align="right" style="background-color:#FFD86B;;"><td colspan="3">
<p><b>Estimation of 10 year risk of coronary heart disease:</b>
<input type="text" value="" size="3" maxlength="3" name="risk"> %
</p>
</table>
</form>
</center>
</body>
</html>