Javascript JQuery时间选择器

Javascript JQuery时间选择器,javascript,jquery,jquery-ui-timepicker,Javascript,Jquery,Jquery Ui Timepicker,我正在使用JQuery Timepicker并添加动态字段,O在这些字段上应用了Timepicker。我希望当用户在这两个字段上选择时间时,它会自动显示小时数 这是我的时间域HTML,通过单击按钮添加更多域,它调用JavaScript方法并添加更多域: <label id="l" style="width:160px;">From</label> <input name="from[]" id="tm1" class="l" type="text" size="15

我正在使用JQuery Timepicker并添加动态字段,O在这些字段上应用了Timepicker。我希望当用户在这两个字段上选择时间时,它会自动显示小时数

这是我的时间域HTML,通过单击按钮添加更多域,它调用JavaScript方法并添加更多域:

<label id="l" style="width:160px;">From</label>
<input name="from[]" id="tm1" class="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;"/>
<label id="l" style="width:20px;">To</label>
<input name="to[]"  id="tm" class="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;"/>
<label id="l" style="width:30px;">Hours</label>
<input name="hours[]" id="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;" readonly="readonly"/>
<input type="button" id="add_sch()" onclick="add_sch('add_sch')" name="btn" value="Add More!" /><br>
来自
到
小时

克隆字段:

<div id="add_sch" style="display:none">
<label id="l" style="width:160px;">From</label>
<input name="from[]" class="tm"  type="text" size="15" height="5px" onblur="" value="" style=":Arial;font-weight:normal;font-size:11px;color:#7c7b77;outline: none;border: 1px solid #c7c7c7;margin:3px 5px;padding:8px 0;padding-left:5px;-moz-box-shadow: 0 0 5px #c7c7c7;-webkit-box-shadow: 0 0 5px #c7c7c7;box-shadow: 0 0 5px #c7c7c7;float:left;border-radius: 5px;"/>
<label id="l" style="width:20px;">To</label>
<input name="to[]" class="tm"  type="text" size="15" height="5px" onblur="" value="" style=":Arial;font-weight:normal;font-size:11px;color:#7c7b77;outline: none;border: 1px solid #c7c7c7;margin:3px 5px;padding:8px 0;padding-left:5px;-moz-box-shadow: 0 0 5px #c7c7c7;-webkit-box-shadow: 0 0 5px #c7c7c7;box-shadow: 0 0 5px #c7c7c7;float:left;border-radius: 5px;"/>
<label id="l" style="width:30px;">Hours</label>
<input name="hours[]" id="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;" readonly="readonly"/></div>

从…起
到
小时
JavaScript:

var counter = 0;
function add_sch (FieldName) {
    counter++;
    var newFields = document.getElementById(FieldName).cloneNode(true);
    newFields.id = '';
    newFields.style.display = 'block';
    var newField = newFields.childNodes;
    for (var i=0;i<newField.length;i++) {
        var theName = newField[i].name
        if (theName)
            newField[i].name = theName + counter;
    }
    var insertHere = document.getElementById(FieldName);
    insertHere.parentNode.insertBefore(newFields,insertHere);
    $(newFields).find('.tm').timepicker();
}
var计数器=0;
函数添加(字段名){
计数器++;
var newFields=document.getElementById(FieldName).cloneNode(true);
newFields.id='';
newFields.style.display='block';
var newField=newFields.childNodes;

对于(var i=0;i在变量中同时输入时间,然后计算时间,您将获得小时数)我认识那个人,但当我添加动态字段时,应如何获得该值为每行指定唯一id表示两个文本框