-6
我正在使用Javascript构建一个风险计算器程序,为此,我有一个1-3的规模,其中零是没有风险,三个是最高风险。对于每个选项(年龄,性别,BMI,血压,体温,吸烟等),我将分配一个数字(0-3)并使用该数字来确定风险百分比。如何在Javascript中分配数字?
实施例:年龄:
18-39 = 0风险
40+ = 2风险
无论用户选择他们的年龄将增加他们的个人百分比。
我该如何编写这个程序?
List<StringWithValue> stringList == new ArrayList<StringWithValue>();
int myRisk;
// no risk = "0";
//some risk = "1";
// risk = "2";
//abnormal risk = "3";
var a = "0", b = "1", c = "2", d = "3"
if(message == "Age") {
alert("Ages 18 to 39 have a lower risk of cancer" + '\n\n' +
"Than for those over 40.");
StringAge = "18-39";
StringValue = "a";
System.out.println("Age" = "a");
StringAge_2 = "40-80";
StringValue = "c";
System.out.println("Age_2" = "c");
} else if(message =="Sex") {
alert("Choose your biological gender" + '\n\n' + "Males are more likely to develop" +
" lung cancer than females.");
} else if(message == "Systolic Blood Pressure") {
alert("Low blood pressure is anything below 100" + 'n\n' + "Normal range is 120-130" +
"High blood pressure is over 135.");
} else if(message =="Diastolic Blood Pressure") {
alert("Low blood pressure is anything below 70" + 'n\n' +"Normal range is 80-85" +
"High blood pressure is over 90.");
} else if(message =="Temperature") {
alert("Below 98.6 degrees Fahrenheit/37 degrees Celsius is unhealthy" + 'n\n' + "Normal range is at exactly 98.6 degrees/37 degrees Celsius" +
"Anything above 98.6 degrees Fahrenheit/37 degrees Celsius is abnormal.");
} else if(message =="Race") {
alert("African Americans have a higher chance of lung cancer" + 'n\n' + "Followed by Caucasians" +
"Asians, Pacific Islanders, Hispanics, and Native Americans have a low percentage.");
}
else if(message == "family") {
alert("Family History of Lung Cancer" + '\n\n' +
"Choose Yes if an immediate family member had " +
"lung cancer.");
"Note: The Calculator is only applicable for persons without a previous diagnosis of lung cancer.");
}
}
function radiobtnchange(units){
if(units == "Standard"){
document.getElementById('lblHeightUnits').innerHTML = "in";
document.getElementById('lblWeightUnits').innerHTML = "lbs";
}
if(units == "Metric"){
document.getElementById('lblHeightUnits').innerHTML = "cm";
document.getElementById('lblWeightUnits').innerHTML = "kg";
}
}
function clearAllFields(theForm) {
if(theForm.age) clearObjValue(theForm.race);
if(theForm.sex) clearObjValue(theForm.pca3);
if(theForm.systolic_blood_pressure) clearObjValue(theForm.free_psa);
if(theForm.diastolic_blood_pressure) clearObjValue(theForm.pro_psa);
if(theForm.bmi) clearObjValue(theForm.height);
if(theForm.temperature) clearObjValue(theForm.weight);
if(theForm.prostate_volume) clearObjValue(theForm.prostate_volume);
if(theForm.num_biopsy_cores) clearObjValue(theForm.num_biopsy_cores);
if(theForm.aua_symptom_score) clearObjValue(theForm.aua_symptom_score);
if(theForm.age) clearObjValue(theForm.age);
if(theForm.psa) clearObjValue(theForm.psa);
if(theForm.familyhistory) clearObjValue(theForm.familyhistory);
if(theForm.dre) clearObjValue(theForm.dre);
if(theForm.biopsy) clearObjValue(theForm.biopsy);
if(theForm.finasteride) clearObjValue(theForm.finasteride);
也就是说* JavaScript的*代码,它是不一样的*的Java *。 – Blorgbeard 2013-04-22 00:07:07
一个不会简单地混合Java和JavaScript代码。 – 2013-04-22 00:27:31