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);
}