Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Timepicker
    primarykey
    data
    text
    <p>I am using JQuery Timepicker and I am adding dynamic fields on which O applied Timepicker. I want that when user selects time on both fields, it will automatically display the number of hours in hours.</p> <p>This is my HTML of time field with a button of add more fields by clicking button it calls method of JavaScript and add more fields:</p> <pre><code>&lt;label id="l" style="width:160px;"&gt;From&lt;/label&gt; &lt;input name="from[]" id="tm1" class="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;"/&gt; &lt;label id="l" style="width:20px;"&gt;To&lt;/label&gt; &lt;input name="to[]" id="tm" class="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;"/&gt; &lt;label id="l" style="width:30px;"&gt;Hours&lt;/label&gt; &lt;input name="hours[]" id="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;" readonly="readonly"/&gt; &lt;input type="button" id="add_sch()" onclick="add_sch('add_sch')" name="btn" value="Add More!" /&gt;&lt;br&gt; </code></pre> <p>Cloning fields:</p> <pre><code>&lt;div id="add_sch" style="display:none"&gt; &lt;label id="l" style="width:160px;"&gt;From&lt;/label&gt; &lt;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;"/&gt; &lt;label id="l" style="width:20px;"&gt;To&lt;/label&gt; &lt;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;"/&gt; &lt;label id="l" style="width:30px;"&gt;Hours&lt;/label&gt; &lt;input name="hours[]" id="l" type="text" size="15" height="5px" onblur="" value="" style="width:auto;" readonly="readonly"/&gt;&lt;/div&gt; </code></pre> <p>JavaScript:</p> <pre><code>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&lt;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(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload