Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C#
more than a day I hav try to calculate the start and end time difference its i ill be working correctly on first selection. when i select again start time its i ill be not change the end time duration i ill try to solve it i hav no idea what i should hav mistak it can any 1 clear it 





HTML
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

  <script type="text/javascript" src="jquery.timepicker.js"></script>
  <link rel="stylesheet" type="text/css" href="jquery.timepicker.css" />



<script type="text/javascript" >

$(function() {
$('#t_start_time').timepicker({
'step': 15
});
});
// temporarily disable end time
$(function() {
$("#t_end_time").prop('disabled', true);
});
// when a start time is chosen
$(function() {
$('#t_start_time').on('changeTime', function () {
// enable the end time input
$('#t_end_time').prop('disabled', false);

// enable the input as a timepicker
$('#t_end_time').timepicker({
minTime: $(this).val(),
showDuration: true,
step: 15,
className: 'endTime'
}).on("changeTime", function () {
var selectedDurationSpan = $(".ui-timepicker-wrapper.endTime").find("li.ui-timepicker-selected").find("span.ui-timepicker-duration");
var selectedDuration = selectedDurationSpan.text().trim().replace(/[()]/g, '');
$("#t_duration").val(selectedDuration);
});
});
});

</script>



HTML
<div class="form-group">
    <label for="t_start_time"> start time:</label>
    <input type="text" id="t_start_time" name="t_start_time" class="form-control ui-timepicker-input" />
</div>
<div class="form-group" id="end_time">
    <label for="t_end_time"> end time:</label>
    <input type="text" id="t_end_time" name="t_end_time" class="form-control ui-timepicker-duration" />
</div>
<div class="form-group" id="duration">
    <label for="t_duration"> duration:</label>
    <input type="text" id="t_duration" name="t_duration" class="form-control ui-timepicker-duration" disabled="true" />
</div>
Posted
Updated 27-Jan-16 19:38pm
v2
Comments
John C Rayan 28-Jan-16 4:31am    
I am struggling to follow you. can you please re-phrase your question.
Member 10678779 28-Jan-16 4:58am    
first time time calculation is run suceecess

after again i hav select start time example: 1:30pm

endtime text box is enable when i select min time only but its i ill be show on all time

i ill check it also minTime: $(this).val(),
i dont no what i should be wrong on this code
John C Rayan 2-Feb-16 9:40am    
where is your change event for start time to calculate the difference.
Can you nicely format your code for a better readability

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900