计算器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计算器</title>
<script type="text/javascript">
window.onload=function() {
var oInput01 = document.getElementById('input01');
var oSelect = document.getElementById('select');
var oInput02 = document.getElementById('input02');
var oBtn = document.getElementById('btn');
oBtn.onclick = function () {
var val01 = oInput01.value;
var val02 = oInput02.value;
switch (oSelect.value) {
case '0'://+
alert((parseFloat(oInput01.value)+parseFloat(oInput02.value) * 100 ) / 100);
break;
case '1'://-
alert((parselFloat(oInput01.value * 100) - parseFloat(oInput02.value) * 100) / 100);
break;
case '2'://*
alert((parselFloat(oInput01.value * 100) * parseFloat(oInput02.value) * 100) / 10000);
break
case '3':// /
alert(parseFloat(oInput01.value * 100) / parseFloat(oInput02.value * 100))
break;
}
}
}
</script>
</head>
<body>
<h1>计算器</h1>
<input type="text" name="" id="input01" />
<select id="select">
<option value="0"></option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
</select>
<input type="text" name="" id="input02" />
<input type="button" name="" value="计算" id="btn" />
</body>
</html>
分数
window.onload = function () {
var score = prompt("请输入分数");
switch(parseInt(scroe/60)){
case 1:
alert("合格");
break;
case 0:
alert("不合格");
break;
}
}
判断星期
var str = promt("请输入数字1-7");
if (str > "7" || str < "1") {
alert("输入不合法");
return;
}
switch (str){
case "7":
alert("星期日");
break;
case "6":
alert("星期六");
break;
case "5":
alert("星期五");
break;
case "4":
alert("星期四");
break;
case "3":
alert("星期三");
break;
case "2":
alert("星期二");
break;
case "1":
alert("星期一");
break;
}
网友评论