javascript分数,javascript成绩评价
Javascript 选择题统计分数
onclick="return scoref(f1)"
创新互联自2013年起,先为五龙口等服务建站,五龙口等地企业,进行企业商务咨询服务。为五龙口企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
script language="JavaScript"
function scoref(f1) {
var score=0;
if(f1.R1.value=="产品观念") score++;
if(f1.R2.value=="集中策略") score++;
if(f1.a1.value=="广告") score++;
if(f1.a2.value=="渗透定价") score++;
if(f1.a3.value=="同心多角化") score++;
if(f1.组合.value=="宽度"+"长度"+"深度"+"关联性") score++;
if(f1.市场.value=="消费者市场"+"生产者市场") score++;
alert("你的成绩为:"+score);
}
/script
注意:
如果下边这段代码有问题的话也不行
if(f1.R1.value=="产品观念") score++;
if(f1.R2.value=="集中策略") score++;
if(f1.a1.value=="广告") score++;
if(f1.a2.value=="渗透定价") score++;
if(f1.a3.value=="同心多角化") score++;
if(f1.组合.value=="宽度"+"长度"+"深度"+"关联性") score++;
if(f1.市场.value=="消费者市场"+"生产者市场") score++;
自己研究吧
=90) B(80-90) C(70-80) D(60-70) E('>用JavaScript写输出分数等级A(>=90) B(80-90) C(70-80) D(60-70) E(
var score=prompt("请输入您的分数","");
if(score!="" !isNaN( parseInt(score))){
score=parseInt(score);
switch (score){
case 100:
case 99:
case 98:
case 97:
case 96:
case 95:
case 94:
case 93:
case 92:
case 91:
case 90:
alert("A");
break;
case 89:
case 88:
case 87:
case 86:
case 85:
case 84:
case 83:
case 82:
case 81:
case 80:
alert("B");
break;
case 79:
case 78:
case 77:
case 76:
case 75:
case 74:
case 73:
case 72:
case 71:
case 70:
alert("C");
break;
case 69:
case 68:
case 67:
case 66:
case 65:
case 64:
case 63:
case 62:
case 61:
case 60:
alert("D");
break;
default:
alert("E");
}
}else{
alert("输入数据有误!")
}
JavaScript 分数校验
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title无标题文档/title
script
function check(){
//获取输入内容
var num = document.form1.number.value;
//判断是否输入了
if(num == ""){
alert("请输入一个数字");
}
//判断是否数字
if(isNaN(num)){
alert("不是数字");
return false;
}else if(!(num = 0 num = 100))//判断值是否在范围之内
{
alert("大小不正确");
return false;
}
return true;
}
/script
/head
body
form name="form1" onSubmit="return check()"
请输入一个数字input type="text" name="number" /input type="submit" value="确定" /
/form
/body
/html
JAVASCRIPT计算加权分数以及学分
script type="text/javascript"
var totalWeightedScore;
var lastScore;
var totalCredit;
var gainCredit;
function checkScore(fs){
if(isNaN(fs) || fs 0 || fs 100){
alert("分数输入错误,范围0-100,请重新输入");
return false;
}
return true;
}
function checkCredit(is){
if(isNaN(is) || is 1 || is 4){
alert("分数输入错误,范围1-4,请重新输入");
return false;
}
return true;
}
function getNextScore(){
var data = window.prompt("请输入下一门课程的成绩,输入-1表示结束", '0');
var fs = parseFloat(data);
if(fs == -1){
endX();
return;
}
if(!checkScore(data)){
getNextScore();
}else{
lastScore = fs;
getNextCredit();
}
}
function getNextCredit(){
var data = window.prompt("请输入课程的学分", '0');
var is = parseInt(data);
if(!checkCredit(is)){
getNextCredit();
}else{
totalCredit += is;
if(lastScore = 60){
gainCredit += is;
}
totalWeightedScore += lastScore * is;
getNextScore();
}
}
function startX(){
lastScore = -1;
totalWeightedScore = 0;
totalCredit = 0;
gainCredit = 0;
getNextScore();
}
function endX(){
if(lastScore == -1){
alert("未输入任何分数与学分");
return;
}
var weightedScore = totalWeightedScore / totalCredit;
weightedScore = Math.round(weightedScore * 100) / 100;
var info = "加权平均分:" + weightedScore
+ "\n总学分数:" + totalCredit
+ "\n及格总学分数:" + gainCredit;
if(gainCredit == totalCredit){
info += "\nAll Pass";
}else if(gainCredit totalCredit / 2){
info += "\n二一不及格";
}
alert(info);
}
/script
input type="button" value=" 开始 " onclick="startX()"/
分享文章:javascript分数,javascript成绩评价
网址分享:http://azwzsj.com/article/dsdgeec.html