switch判断成绩jsp案例
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type="text/javascript">
function test(a){
if(isNaN(a)||a<0||a>100)return;
var content="";
var _a=parseInt(a/10)
switch(_a){
case 10:
content ="优秀";
break;
case 9:
content ="优秀";
break;
case 8:
content ="良好";
break;
case 7:
content ="一般";
break;
case 6:
content ="及格";
break;
default:
content="不及格";
}
return content;
}
document.write(test(40));
document.write(test(90));
</script>
<body>
</body>
</html>
//