Home > Backend Development > PHP Tutorial > 怎么让上拉列表显示半小时的数据

怎么让上拉列表显示半小时的数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:54:54
Original
836 people have browsed it

如何让下拉列表显示半小时的数据
我先设置一个控件里显示早上8:30到15点之间的数据,即8:30,9:00,9:30,10:00……15:00以此类推.用JS实现如果能用my97控件实现更好


------解决方案--------------------
有时简单,最是最有效的方法
我还是帮你写个吧动态的吧
<br />
<br />
<select id="sel1"></select><br />
<br />
<script><br />
  //selObj  select 对象<br />
  //begin 开始时间<br />
  //edn 结束时间<br />
  // step步长<br />
  function fn(selObj,begin,end,step){<br />
    function mm(str){<br />
      var re=0;<br />
      str.replace(/(\d+):(\d+)/,function(_,h,m){ re=h*60+m*1  });<br />
      return re;<br />
    }<br />
    function fmt(v){return (v+100+'').slice(1)}<br />
    var bv=mm(begin),ev=mm(end);<br />
    console.info( bv,ev )<br />
    for(i=bv;i<=ev;i+=step){<br />
      console.info( fmt(i/60>>0)+':'+fmt(i%60) )<br />
      var text=fmt(i/60>>0)+':'+fmt(i%60);<br />
      selObj.options.add(new Option(text,text))<br />
    }<br />
  }<br />
  <br />
 fn(  document.getElementById("sel1") ,'1:00','2:30',30)<br />
<script><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template