js实现时间段选择(select) API

<style>
#_contents{
  display: flex;
  display: -webkit-flex;
  display: -webkit-box;
  display: -moz-flex;
}
#_contents select{
  width:50px;
}
</style>
<script>
var str = "";
document.writeln("<div class=\"aui-content aui-margin-b-15\">");
str += "<ul class=\"aui-list aui-form-list\">";
str += "<li class=\"aui-list-item\">";
str += "<div class=\"aui-list-item-inner\">";
str += "<div class=\"aui-list-item-label\">时间段</div>";
str += "<div class=\"aui-list-item-input\" id=\"_contents\" visibility:hidden\>";
str += "<select name=\"starhour\" id=\"starhour\">";
for (h = 6; h <= 9; h++) {
    str += "<option value=\"0" + h + "\">0" + h + "</option>";
}
for (h = 10; h <= 20; h++) {
    str += "<option value=\"" + h + "\">" + h + "</option>";
}
str += "</select>";
str += "<select name=\"starminute\" id=\"starminute\">";
for (m = 0; m <= 0; m++) {
    str += "<option value=\"0" + m + "\">0" + m + "</option>";
}
for (m = 3; m <= 3; m++) {
    str += "<option value=\"" + m + "\">" + m + "0</option>";
}
str += "</select>";
str += "<select name=\"endhour\" id=\"endhour\">";
for (h = 6; h <= 9; h++) {
    str += "<option value=\"0" + h + "\">0" + h + "</option>";
}
for (h = 10; h <= 20; h++) {
    str += "<option value=\"" + h + "\">" + h + "</option>";
}
str += "</select>";
str += "<select name=\"endminute\" id=\"endminute\">";
for (m = 0; m <= 0; m++) {
    str += "<option value=\"0" + m + "\">0" + m + "</option>";
}
for (m = 3; m <= 3; m++) {
    str += "<option value=\"" + m + "\">" + m + "0</option>";
}
str += "</select>";
str += "</div>";
str += "</div>";
str += "</li>";
str += "</ul>";
str += "<div  class=\"aui-btn aui-btn-info\">";
str += "<input name=\"queding\" type=\"button\" onclick=\"_select()\" value=\"\u786e\u5b9a\" style=\"font-size:12px\" /></div>";
str += "</div>";
document.writeln(str);
var _fieldname;
function _SetTime(tt) {
    _fieldname = tt;
    var ttop = tt.offsetTop;    //TT控件的定位点高
    var thei = tt.clientHeight;    //TT控件本身的高
    var tleft = tt.offsetLeft;    //TT控件的定位点宽
    while (tt = tt.offsetParent) {
        ttop += tt.offsetTop;
        tleft += tt.offsetLeft;
    }
    document.all._contents.style.top = ttop + thei + 4;
    document.all._contents.style.left = tleft;
    document.all._contents.style.visibility = "visible";
}
function _select() {
    _fieldname = $api.val($api.byId('starhour')) + ":" + $api.val($api.byId('starminute')) + "~" + $api.val($api.byId('endhour')) + ":" + $api.val($api.byId('endminute'));
    $api.html($api.byId('time'), _fieldname);
}
 </script>
<body>
    <input name="star" id="star" type="text" readonly  onclick="_SetTime(this)"/>
    <div id="time"></div>
</body>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值