zoukankan      html  css  js  c++  java
  • 初始化时间下列框的脚本

    var oStartTime = new Date(2003,12,12,7,0);
            
    var oEndTime = new Date(2003,12,12,23,0);
            
    //初始化开始时间和结束时间
            var oSelect = document.all("cboStartTime");
            
    var oEndSelect = document.all("cboEndTime");
            
    var oTime = new Date();
            
    for(var i= 0;oStartTime<oEndTime;i++)
            {
                
    var iCount = 15 * i;
                
    //alert("Current setting is " + oStartTime.toLocaleString() + "  i=" + i + "  iCount=" + iCount + "  strValue=" + strValue );
                oStartTime = new Date(2003,12,12,7,0);
                oStartTime.setMinutes(iCount);
                
    var strValue = oStartTime.getHours() + ":" + oStartTime.getMinutes();
                
    //alert("Current setting is " + oStartTime.toLocaleString() + "  i=" + i + "  strValue=" + strValue );
                var oOption = document.createElement("OPTION");
                oOption.text 
    = strValue;
                oOption.value 
    = strValue;
                
    if(oStartTime.getHours() == oTime.getHours() && oStartTime.getMinutes() == 0)
                oOption.selected 
    = true;
                oSelect.add(oOption);
                
    var oOption1 = document.createElement("OPTION");
                oOption1.text 
    = strValue;
                oOption1.value 
    = strValue;
                
    if(oStartTime.getHours() == (oTime.getHours()+1&& oStartTime.getMinutes() == 30)
                oOption1.selected 
    = true;
                oEndSelect.add(oOption1);
            }




    我原来的写法:
    var oStartTime = new Date(2003,12,12,7,0);
      var oEndTime = new Date(2003,12,12,23,0);
      //初始化开始时间和结束时间
      var oSelect = document.all("cboStartTime");
      var oEndSelect = document.all("cboEndTime");

      var oTime = new Date();
      for(var i= 0;oStartTime<oEndTime;i++)
      {
       oStartTime.setMinutes(15*i);
       var strValue = oStartTime.getHours() + ":" + oStartTime.getMinutes();
       //alert("Current setting is " + oStartTime.toLocaleString() + "  i=" + i + "  strValue=" + strValue );
       var oOption = document.createElement("OPTION");
       oOption.text = strValue;
       oOption.value = strValue;
       oSelect.add(oOption);
       var oOption1 = document.createElement("OPTION");
       oOption1.text = strValue;
       oOption1.value = strValue;
       oEndSelect.add(oOption1);
    }

  • 相关阅读:
    2019年8月7日 封装 7夕快乐
    2019年8月4日 多态 苗苗苗苗苗
    2019年7月31日 选课系统
    字符串类型的输入输出
    getline()函数的使用
    出栈序列统计
    因式分解
    质数
    多项式求和
    回文数字
  • 原文地址:https://www.cnblogs.com/liubiqu/p/140188.html
Copyright © 2011-2022 走看看