How to get table's one column data in javascript?
How can I get a table’s one column data in javascript? I am getting two textboxes value in javascript and display the result in a single div, now how can I get only one column data (which is date and time) which is retrieved from database instead of textboxes and check this column’s time if it is like 2:30PM, 15 minutes (2:15pm) it should display this time or maybe with other column’s data as table in popup message?
<script> document.addEventListener('DOMContentLoaded', function(event) { function showTime(hours, minutes) { return ((hours < 10) ? '0' : '') + hours + ':' + ((minutes < 10) ? '0' : '') + minutes; } function calculate_time(hour_start, hour_end) { startTime = new Date('1-1-1 ' + hour_start); endTime = new Date('1-1-1 ' + hour_end); var difference = endTime - startTime; difference /= 1000 * 60; var hours = Math.floor(difference / 60); var mins = Math.floor(difference % 60); return { hours: hours, minutes: mins }; } var timer = null; function getTimeDifference() { var start = document.getElementById('startTime').value; var end = document.getElementById('endTime').value; const time = calculate_time(start, end); document.getElementById('diff_hour').innerHTML = showTime(time.hours, time.minutes) // convert to miliseconds and subtract 10minutes to get notified const notifyTime = (time.hours * 60 * 60 * 1000) + (time.minutes * 60 * 1000) - (15 * 60 * 1000); clearTimeout(timer) if (notifyTime > 0) { timer = setTimeout(() => { console.log('get ready') clearTimeout(timer) }, notifyTime) } } getTimeDifference(); document.getElementById('endTime').addEventListener('change', function() { getTimeDifference() }); }) </script>
<form id="calculate" action=""> <div> <div class="form-group col-md-4"> <label for="departure"><strong>Arrival Time </strong></label> <?php $date = date("H:i") ?> <input id="startTime" type="time" name="hour_start" value="<?= $date ?>"> </div> <br /> <div class="form-group col-md-4"> <label for="departure"><strong>Departure Time</strong></label> <?php $date = date("H:i") ?> <input id="endTime" type="time" name="hour_end" value="<?= $date ?>"> </div> <p id="diff_hour"></p> </div> </form>