switch语句的问题
这样写哪里出了问题呢
2018-03-08
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch</title>
<script type="text/JavaScript">
function b() {
var myweek = parseInt(document.getElementById("a").value);
switch (myweek)
{
case 1:
case 2:
alert("学习理念知识");
break;
case 3:
case 4:
alert("到企业实践");
break;
case 5:
alert("总结经验");
break;
case 6:
case 7:
alert("周六、日休息和娱乐");
break;
default:
alert("请输入正确的日期!")
}
}
</script>
</head>
<body>
<div>请输入工作日:</div>
<input type="text" id="a">
<input type="button" value="查看工作安排" onclick="b()">
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch</title>
<script type="text/JavaScript">
function b(){
var myweek=parseInt( document.getElementById('a').value);
switch (myweek)
{
case 1:
case 2:
document.write("学习理念知识");
break;
case 3:
case 4:
document.write("到企业实践");
break;
case 5:
document.write("总结经验");
break;
case 6:
case 7:
document.write("周六、日休息和娱乐");
break;
default:
document.write("出现错误了哦!")
}
}
</script>
</head>
<body>
<div>请输入工作日:</div>
<input type="text" id="a">
<input type="button" value="查看工作安排" onclick="b()">
</body>
</html>
</html>
举报