rambo_jr
02-29-2012, 08:57 PM
coming from C++ back ground and new going into Java Script
i cant really seem to get the if Else statement working
What i am trying to do is put a error alert box in if any one types in anything over 100 it should show that but whats happening is if i type in 600 its showing the Error Box but also saying you got an A+ after i click ok on the Error Box..
the else i showing an Error i cant seem to figure how can i get this part working
script type='text/javascript'>
function show(which) {
var mark = parseInt(which.value,10) || 0;
if (mark >100)
which.value = mark;
alert("Please Enter between 0 & 100 !");
else
if (mark <100)
var mod = which.id;
var grade = "Failed";
if (mark >=40) {grade = "D"}
if (mark >=60) {grade = "C"}
if (mark >=78) {grade = "B"}
if (mark >=85) {grade = "A"}
if (mark >=93) {grade = "A+"}
alert ("Your grade for " + mod + " is " + grade);
}
</script>
i cant really seem to get the if Else statement working
What i am trying to do is put a error alert box in if any one types in anything over 100 it should show that but whats happening is if i type in 600 its showing the Error Box but also saying you got an A+ after i click ok on the Error Box..
the else i showing an Error i cant seem to figure how can i get this part working
script type='text/javascript'>
function show(which) {
var mark = parseInt(which.value,10) || 0;
if (mark >100)
which.value = mark;
alert("Please Enter between 0 & 100 !");
else
if (mark <100)
var mod = which.id;
var grade = "Failed";
if (mark >=40) {grade = "D"}
if (mark >=60) {grade = "C"}
if (mark >=78) {grade = "B"}
if (mark >=85) {grade = "A"}
if (mark >=93) {grade = "A+"}
alert ("Your grade for " + mod + " is " + grade);
}
</script>