Use the following code to create a basic inputEx TimeIntervalField.
1 | var field = new inputEx.TimeIntervalField({parentEl: 'container1', label: 'Length',value:82800}); |
2 | var button = inputEx.cn('button', null, null, 'getValue'); |
3 | YAHOO.util.Event.addListener(button, "click",function() { |
4 | alert(field.getValue()+" (seconds)"); |
5 | }); |
6 | YAHOO.util.Dom.get('container1').appendChild(button); |
view plain | print | ? |
You can set the fields and separators options of the combine field to customize the field
1 | var units = inputEx.TimeIntervalField.units; |
2 | var unitsStr = inputEx.messages.timeUnits; |
3 | var n=[]; for(var i=1;i !=30;i++){ n.push(i); } |
4 | var fields = [ |
5 | {type: 'select', choices: n }, |
6 | { |
7 | type: 'select', |
8 | choices: [ |
9 | { value: units.DAY, label: unitsStr.DAY }, |
10 | { value: units.MONTH, label: unitsStr.MONTH }, |
11 | { value: units.YEAR, label: unitsStr.YEAR } |
12 | ] |
13 | } |
14 | ]; |
15 | |
16 | new inputEx.TimeIntervalField({ |
17 | parentEl: 'container2', |
18 | value: 60*24*2, // 2 days |
19 | unit: inputEx.TimeIntervalField.units.MINUTE, |
20 | label: 'Continue', |
21 | fields: fields, |
22 | separators: ["for ", " ", false] |
23 | }); |
view plain | print | ? |