<script language="JavaScript">
   var num=window.prompt("请输入数字","");
   switch(num){
           case 0:alert("Sunday");
            break;
           case 1:alert("Monday"); 
           break;
           case 2:alert("Tuesday");
              break;
           case 3:alert("Wednesday");
            break;
           case 4:alert("Thursday");
           break;
           case 5:alert("Friday");
             break;
           case 6:alert("Saturday");
            break;
           }
</script>

解决方案 »

  1.   

    case "0"
    case "1"
    case "2"
    case "3"
    ...
    加上引号,因为你得到的是字符串,不是数字,
    或者用parseInt转换成数字
      

  2.   

    var num=window.prompt("请输入数字","");
    switch(num){
    case "0":alert("Sunday");
    break;
    case "1":alert("Monday"); 
    break;
    case "2":alert("Tuesday");
    break;
    case "3":alert("Wednesday");
    break;
    case "4":alert("Thursday");
    break;
    case "5":alert("Friday");
    break;
    case "6":alert("Saturday");
    break;
    }