Hi,
I want progressbar for 'FOR' loop. when the loop stop then progress bar status will be 100%.can anyone help
Hi,
I want progressbar for 'FOR' loop. when the loop stop then progress bar status will be 100%.can anyone help
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Mar 15, 2023, 2:06 AM EDT
Check this
$(document).ready(function () { let progress = 0; let forValue = 1000; for (let i = 0; i setTimeout(resolve, msec)); } }); Progress BarTuhin PaulRank #7 · 71.9K reputationPosted Mar 19, 2023, 9:05 PM EDT
$(document).ready(function () { let progress = 0; let forValue = 1000; for (let i = 0; i setTimeout(resolve, msec)); } }); Progress Bar function updateProgressBar(progress) { document.getElementById("progressBar").setAttribute("style", "width:" + progress.toString() + "%"); document.getElementById("progressBar").setAttribute("aria-valuenow", progress.toString()); document.getElementById("progressBarText").innerText = progress.toString() + "%"; } $(document).ready(function () { let progress = 0; let forValue = 1000; let interval = setInterval(function () { progress++; updateProgressBar(progress); if (progress >= 100) { clearInterval(interval); } }, 90000 / forValue); });In the modified code, I had replaced the original for loop with a setInterval function that will increment the progress bar every time it's called. The progress value is updated on the interval by incrementing it by 1 until it reaches 100. I added a new function updateProgressBar to update the progress bar's text with the current progress percentage. This function is called every time the progress bar is updated.