日期:2014-05-16  浏览次数:20355 次

JavaScript中写入时间下拉列表
<script type="text/javascript">
  function writeOptions(starttime,endtime)
            {
      
      var counter;
  for(counter=starttime;counter<=9;counter++)
  {
 
  document.write("<option value=0"+counter+">"+"0"+counter);
   
  }
 
  for(counter=10;counter<=endtime;counter++)
  {
 
  document.write("<option value="+counter+">"+counter);
 
 
  }
 
  }
 
 
  </script>
<td>
<select name="startselecttime_hh" style="width:expression((this.offsetWidth>40)?'auto':'40')">
    <script>
   writeOptions(0,23); 
   </script>       
    </select><a>时</a>
<td>
<td>
<select name="startselecttime_mm" style="width:expression((this.offsetWidth>40)?'auto':'40')">
    <script>
   writeOptions(0,59); 
   </script>       
    </select><a>分</a>
<td>
<script type="text/javascript">
var startselecttime_hh=document.getElementById("startselecttime_hh");
for (i=0;i<startselecttime_hh.length;i++){    
        
if(starttime_hh==startselecttime_hh.options[i].value){
                                                                                                     
startselecttime_hh.options[i].selected=true;
}

    }[/color][color=brown]
</script>