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++;
自己研究吧
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("輸入數據有誤!")
}
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
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://vcdvsql.cn/article42/dsdgeec.html
成都網站建設公司_創新互聯,為您提供用戶體驗、Google、網站制作、企業建站、域名注冊、定制網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯