时间显示在下拉列表中

时间:2014-10-02 19:15:59

标签: javascript jquery html dojo

我可以使用jquery或dojo或简单的HTML在单独的下拉列表中显示小时和分钟。请建议。 以下是示例代码:

<input id="time" data-dojo-type="dijit/form/TimeTextBox" required="true"
data-dojo-props="constraints: { timePattern: 'HH:mm:ss', clickableIncrement: 'T00:05:00', visibleIncrement: 'T00:05:00', visibleRange: 'T01:00:00' }" />

2 个答案:

答案 0 :(得分:2)

我对道场的了解不多,但如果有所帮助,我就能做到这一点:

Time:
<input id="timeHours" data-dojo-type="dijit/form/TimeTextBox" required="true" data-dojo-props="constraints: { timePattern: 'HH', clickableIncrement: 'T01:05:00', visibleIncrement: 'T01:00:00', visibleRange: 'T24:00:00' }" />
:
<input id="timeMins" data-dojo-type="dijit/form/TimeTextBox" required="true" data-dojo-props="constraints: { timePattern: 'mm', clickableIncrement: 'T00:05:00', visibleIncrement: 'T00:05:00', visibleRange: 'T00:60:00' }" />

require([
    "dojo/_base/lang", "dijit/registry", "dojo/ready", "dijit/form/TimeTextBox", "dojo/parser"
], function(lang, registry, ready) {
    ready(function() {
        var timeH = registry.byId("timeHours"),
            timeM = registry.byId("timeMins");
    });
}); 

答案 1 :(得分:0)

由于我正在研究Dojo并在SO上查看许多TimeTextBox问题,我想我可以回答其中的一些问题。

这是我为这个问题做的JS小提琴。我用了一个小时的增量,只显示了小时数,然后我在分钟内做同样的事情。如果您想要5分钟的间隔,请更改

pickerMax: 'T00:59:00',
clickableIncrement: 'T00:01:00',
visibleIncrement: 'T00:01:00'

pickerMax: 'T00:55:00',
clickableIncrement: 'T00:05:00',
visibleIncrement: 'T00:05:00'

注意:pickerMinpickerMax需要Dojo 1.10.4。

h = new dijit.form.TimeTextBox({
    constraints: {
        timePattern: 'HH',
        pickerMin: 'T00:00:00',
        pickerMax: 'T23:00:00',
        clickableIncrement: 'T01:00:00',
        visibleIncrement: 'T01:00:00'
    }
});
m = new dijit.form.TimeTextBox({
    constraints: {
        timePattern: 'mm',
        pickerMin: 'T00:00:00',
        pickerMax: 'T00:59:00',
        clickableIncrement: 'T00:01:00',
        visibleIncrement: 'T00:01:00'
    }
});

在此处试试:http://jsfiddle.net/tfpjmbs2/1/