Making progress bar update with javascript.

<html>
  <head>
    <style>
      #Progress_Status {
        display: block;
        position: relative;
        width: 100%;
        height: 35px;
        background-color: #ddd;
        margin: auto;
        text-align: center;
      }

      #myprogressBar {
        position: absolute;
        left: 0;
        width: 1%;
        height: 35px;
        background: #4CAF50;
        text-align: center;
        line-height: 32px;
        color: black;
        margin: auto;
       
      }
    </style>
  </head>
  <body>
 
    <div id="Progress_Status">
      <div id="myprogressBar">0%</div>
    </div>


    <button onclick="update()">Start Upload</button>
   
    <script>

    function update() {
      var element = document.getElementById("myprogressBar"); 
      var width = 1;
      var identity = setInterval(scene, 10);
      function scene() {
        if (width >= 100) {
          clearInterval(identity);
        } else {
          width++;
          element.style.width = width + '%';
          element.innerHTML = width * 1  + '%';
        }
      }
    }

</script>
  </body>
</html>

Comments

Popular posts from this blog

datatable with both top and bottom scroll bar.

Display Loader and disable page while waiting for ajax request

Remove GIT integration from VSCode