I have a countdown timer in a list control that tells the user how much time they have left to complete a task. However, it's only showing up on the first record. I'm assuming there needs to be a loop to show through the rest of the list, but I can't figure that part out.
Here's the javascript.
I have the results showing in a Custom Control on the list with this.
Again, it just shows up on the first record. How would I loop to show them all? I will be making the 'currentdate' and 'enddate' a variable next. Once time has expired then the record won't show up anymore.
Or is there a better way to do this.
Here's the javascript.
Code:
function countdown() { var currentDate = "tue Jan 09 2020 09:06 39"; var currentTime = "19:14:14.9300000"; // Set the date we're counting down to var countDownDate = new Date(currentDate).getTime() + 43200000; // Update the count down every 1 second var x = setInterval(function() { // Get today's date and time var now = new Date().getTime(); // Find the distance between now and the count down date var distance = countDownDate - now; // Time calculations for days, hours, minutes and seconds var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); // Output the result in an element with id="demo" document.getElementById("demo").innerHTML = hours + "h " + minutes + "m " + seconds + "s "; // If the count down is over, write some text if (distance < 0) { clearInterval(x); document.getElementById("demo").innerHTML = "EXPIRED"; } }, 1000); }
I have the results showing in a Custom Control on the list with this.
Code:
function TimeLeft_render as c (ds as p, tmpl as p) 'Specify the Xbasic that returns the HTML for this control. 'This function must return TimeLeft_render, which should 'contain the HTML that will be displayed. 'The 'ds' argument that is passed in contains the current 'values for each of the fields in the current List row. 'For example: ds.data("Firstname") '------------------------------------------------------------------- on error goto TimeLeft_xbasicError 'Write Xbasic code here that returns the HTML to be displayed by this control TimeLeft_render = <<%html% <p id="demo"></p> %html% end TimeLeft_xbasicError: TimeLeft_render = "Error in custom control xbasic: " + error_text_get() end function
Or is there a better way to do this.
Comment