User:Ujjwal Rastogi/sandbox



function calcScore(inputID) {	var score = document.forms["CHADSCORE"]["result"].value; //alert("input 1 "+document.forms["CHADSCORE"]["input1"].checked); //alert("input 2 "+document.forms["CHADSCORE"]["input2"].checked); //alert("input 3 "+document.forms["CHADSCORE"]["input3"].checked); //alert("input 4 "+document.forms["CHADSCORE"]["input4"].checked); //alert("longanswer "+document.forms["CHADSCORE"]["longanswer"].value);

if(document.forms["CHADSCORE"]["input1"].checked == 1 && inputID == "1") {

score++; }

if(document.forms["CHADSCORE"]["input2"].checked == 1 && inputID == "2") {		score++; }

if(document.forms["CHADSCORE"]["input3"].checked == 1 && inputID == "3") {		score++; }

if(document.forms["CHADSCORE"]["input4"].checked == 1 && inputID == "4") {		score++; }

if(document.forms["CHADSCORE"]["input5"].checked == 1 && inputID == "5") {		score++; score++; }

if(document.forms["CHADSCORE"]["input1"].checked == 0 && inputID == "1") {

score--; }

if(document.forms["CHADSCORE"]["input2"].checked == 0 && inputID == "2") {

score--; }

if(document.forms["CHADSCORE"]["input3"].checked == 0 && inputID == "3") {

score--; }

if(document.forms["CHADSCORE"]["input4"].checked == 0 && inputID == "4") {

score--; }

if(document.forms["CHADSCORE"]["input5"].checked == 0 && inputID == "5") {

score--; score--; }

document.forms["CHADSCORE"]["result"].value = score;

if(document.forms["CHADSCORE"]["result"].value == 0) {		document.forms["CHADSCORE"]["longanswer"].value = "Low Risk: Consider Aspirin or no Anticoagulation"; }	else if(document.forms["CHADSCORE"]["result"].value == 1) {		document.forms["CHADSCORE"]["longanswer"].value = "Moderate Risk: Consider Aspirin or Warfarin"; }	else if(document.forms["CHADSCORE"]["result"].value >= 2) {		document.forms["CHADSCORE"]["longanswer"].value = "High Risk: Warfarin therapy"; } }

