Javascript脚本没有加载?我究竟做错了什么?

时间:2014-08-20 18:07:03

标签: javascript load

大家好,我正在搞乱javascript尝试创建一个倒数计时器!但是我觉得head部分的javascript没有加载,因为即使警报消息也没有出现!我是新手,伙计我做错了什么?我怎样才能将我的变量放在html上,以便它们显示出来?谢谢你的时间......这是我的代码:

               <html>
              <head>
                 <script type="text/javascript">
                 alert("welcome");
                      function calc() {
                        var year,month,date,hour,minutes,seconds,temp ;
                        temp = new Date();
                        year = temp.getFullYear();
                        month = temp.getMonth();
                        date = temp.getDate();
                        hour = temp.getHours(); 
                        minutes = temp.getMinutes();
                        seconds = temp.getSeconds();


                       var thenyear,thenmonth,thendate,thenhour,thenminutes,thenseconds ;
                       var difyear,difmonth,difdate,difhour,difminutes,difseconds ;
                       thenyear = document.getElementById("year").value ;
                       thenmonth = document.getElementById("Month").value;
                       thendate = document.getElementById("date").value;
                       thenhour = document.getElementById("hour").value;
                        thenminutes = document.getElementById("min").value;
                       thenseconds = document.getElementById("sec").value;

                      difyear= thenyear - year ;
                      difmonth = thenmonth -month ;
                      difdate  = thendate - date ;
                       difhour = thenhour - hour;  
                       difminutes =thenminutes - minutes ;
                      difseconds = thensec - seconds ;
                 alert("Time Remaing": + difyear + "Years" + difmonth +" Months" + difhour + "Hours" + difminutes + "Minutes" + difseconds+ " Seconds");
            }


</script>
</head>
<body>
<p> Countdown Timer </p>
<form onsubmit="calc();">
Date/Month/Year 
<select id="date" name="date">
  <script type="text/javascript">

  for(var i = 1; i < 32; i++){
    document.write('<option value="'+i+'">'+i+'</option>');
  }
  </script>
</select>
<select id="Month" > 
<option value="1">January </option>
<option value="2">February </option>
<option value="3">March </option>
<option value="4">April </option>
<option value="5">May </option>
<option value="6">June </option>
<option value="7">July </option>
<option value="8">August </option>
<option value="9">September </option>
<option value="10">Octomber </option>
<option value="11">November </option>
<option value="12">December</option>
</select>
<select id="year" name="year">
  <script type="text/javascript">
  var myDate = new Date();
  var year = myDate.getFullYear();
  for(var i = year; i < 3001; i++){
    document.write('<option value="'+i+'">'+i+'</option>');
  }
  </script>
</select> <br>
Hour(0-23)/Minutes/Seconds

  <input type="text" id="hour"> 
  <input type="text" id="min">
  <input type="text" id="sec">
  <input type="submit" value="Submit">
</form>



</body>
</html>

0 个答案:

没有答案