Hello everyone, I need some help

Hello guys! I am asked to make Stop countdown time and I want stop countdown when status change , But when i change status all my text is deleted, i want keep last value and show them when status change “CALL” to “CONFIRM”, when status change “CONFIRM” to “CALL” the countdown start with current time
this link to codepen
Stop Countdown time

Hi,

What do you mean by ‘text’. You mean the timer itself?
I hope I’ve understood you. Looking at the code, you cannot clear the interval because you change the time back to the original duration as soon as it hits 0.

if (timer-- < 0) {
               timer = duration;
           }

And I don’t see any code that tells you when to change your status. There’s a condition that says what happens when the status changes but nothing that makes that status change. Maybe if timer hits zero, you change the status? Then of course the text of the timer will be gone as it is no longer running. You cannot keep a value once it has been cleared. The last value would be zero, right? That would be the next statement then. Take the element, take the innerHTML or innerText and give it that last value.
I hope I’m making sense.

Greets,
Karin

Greets,
Karin

Thank you so much ,I really appreciate it.
I apologize my English is not very good, so my wording may be inaccurate. Almost here i use google translate, I missing some code! this code I want make the countdown time have limit time = “time” for one job, When i finish status change to “Confirm” to stop it and when have new job start a new life cycle
here the link

Hi,

I just read your message. I find it hard to understand but I have the impression that you are making progress. The code is beginning to work. You can change the status and your clock is running. But the interval is not being cleared properly is it? I think you are creating a new interval before you are clearing the old one. I would clear the old one first and then start up a new interval. And you have not yet told the program what you want to happen when the status goes back to ‘confirm’. But it’s already better, ask whatever question you need to ask.

Greets,
Karin

1 Like

Hi! Thank you for your suggestion .I have found the solution with switch/case Statement and when status goes back to ‘confirm’. That is, the work is completed and the countdown stops,

Great! Keep up the good work!
Karin