JS加载Html的select控件

 

 

 

  function BindDatas() { var myDate=new Date(); var cYear=myDate.getFullYear(); //得到当前年 var cMonth=myDate.getMonth()+1; //得到当前月份 var cDate=myDate.getDate(); //得到日期号 var cHour=myDate.getHours();//得到小时 var cMin=myDate.getMinutes();//得到分钟 for(var i=0;i<3;i++) { document.getElementById("tYear").options.add(new Option(cYear,cYear)); cYear++; } for(i=0;i<24;i++) { document.getElementById("tMonth").options.add(new Option(Format1(i+1),Format1(i+1))); } for(i=0;i<31;i++) { document.getElementById("tDate").options.add(new Option(Format1(i+1),Format1(i+1))); } for(i=0;i<24;i++) { document.getElementById("tHour").options.add(new Option(Format1(i),Format1(i))); } for(i=0;i<60;i++) { document.getElementById("tMinute").options.add(new Option(Format1(i),Format1(i))); } document.getElementById("tMonth").selectedIndex=cMonth-1; document.getElementById("tDate").selectedIndex=cDate-1; document.getElementById("tHour").selectedIndex=cHour; document.getElementById("tMinute").selectedIndex=cMin; document.getElementById("SendByTime").style.display="none"; } ---------------------------- <tbody id="SendByTime"> <tr align="center" class="pop_bgcolor"> <td height="30">  </td> <td align="left" style="padding-left: 8px;" mce_style="padding-left: 8px;"> <select id="tYear" name="tYear"> </select> 年 <select id="tMonth" name="tMonth"> </select> 月 <select id="tDate" name="tDate"> </select> 日 <select size="1" id="tHour"> </select> 时 <select size="1" id="tMinute"> </select> 分 </td> </tr> </tbody> 

         

 

  

 

 

 

 

你可能感兴趣的:(JS加载Html的select控件)