How can I fix the progress bar not updating after clicking submit on my website?

Hello, hope everyone is keeping well.

I’m trying to add a progress bar to the blog page of my website: https://ulx1rv79plsm6f59-66498363644.shopifypreview.com (under petition, on the main menu, the first blog) password: impactful.

I’d like it to be how the progress bar is on the change.org website (https://www.change.org/p/california-state-senate-end-child-marriage-in-california)).

The progress bar doesn’t progress once I click the contact form submit button. Even though the counter changes every time I click submit, by the time the page reloads, the counter sets to 0. I need help to have the counter value persist even after page reloads.

I’m open to suggestions for apps as well, free or paid.

Any help will be greatly appreciated.

progress-bar.liquid:

{{ 'section-contact-form.css' | asset_url | stylesheet_tag }}
{{ 'progress-bar.js' | asset_url | script_tag }}

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

  
    {%- if section.settings.heading != blank -%}
      ## {{ section.settings.heading | escape }}
    {%- else -%}
      ## {{ 'templates.contact.form.title' | t }}
    {%- endif -%}
    {%- form 'contact', id: 'ContactForm', class: 'isolate' -%}
      {%- if form.posted_successfully? -%}
        ## {% render 'icon-success' %} {{ 'templates.contact.form.post_success' | t }}
      {%- elsif form.errors -%}
        
          ## {% render 'icon-error' %} {{ 'templates.contact.form.error_heading' | t }}
        

        
          - {{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }}
            
          
        

      {%- endif -%}
      
      {%- for block in section.blocks -%}
          {%- case block.type -%}
            {%- when 'bar' -%}
               
                

              

          {%- endcase -%}
      {%- endfor -%}
      
      
        

          
          
        

        
          
          
          {%- if form.errors contains 'email' -%}
            <small>
              {{ 'accessibility.error' | t }}
              {% render 'icon-error' %}{{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }}
            </small>
          {%- endif -%}
        

      

      
        
        
      

      
        
        
      

      
        
      

    {%- endform -%}
  

{% schema %}
{
  "name": "Progress bar",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "text",
      "id": "heading",
      "default": "Contact form",
      "label": "Heading"
    },
    {
      "type": "select",
      "id": "heading_size",
      "options": [
        {
          "value": "h2",
          "label": "t:sections.all.heading_size.options__1.label"
        },
        {
          "value": "h1",
          "label": "t:sections.all.heading_size.options__2.label"
        },
        {
          "value": "h0",
          "label": "t:sections.all.heading_size.options__3.label"
        }
      ],
      "default": "h1",
      "label": "t:sections.all.heading_size.label"
    },
    {
      "type": "select",
      "id": "color_scheme",
      "options": [
        {
          "value": "accent-1",
          "label": "t:sections.all.colors.accent_1.label"
        },
        {
          "value": "accent-2",
          "label": "t:sections.all.colors.accent_2.label"
        },
        {
          "value": "background-1",
          "label": "t:sections.all.colors.background_1.label"
        },
        {
          "value": "background-2",
          "label": "t:sections.all.colors.background_2.label"
        },
        {
          "value": "inverse",
          "label": "t:sections.all.colors.inverse.label"
        }
      ],
      "default": "background-1",
      "label": "t:sections.all.colors.label"
    },
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 36
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 36
    }
  ],
  "blocks": [
    {
      "type": "bar",
      "name": "Progress bar",
      "settings": [
        {
          "type": "number",
          "id": "total",
          "default": 500,
          "label": "The total number of signatures wanted."
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Progress bar"
    }
  ]
}
{% endschema %}

progress-bar.js:

$(document).ready(function() {
  let progressbar = document.getElementById("download");
  var value = progressbar.getAttribute("data-total");
  var count = 0;

  function updateProgressBar(value) {
    if (value >= 0 && value <= 100) {
      progressbar.style.width = value + "%"; 
    }
  }

  function handleInput() {
    console.log("hello")
    console.log("Total: " + value);
    count++;
    
    console.log("Count: " + count);
    var num = parseInt(value);
    var add = (1/num) * 100;
    console.log("Current: " + add);
    updateProgressBar(add);
}
  document.getElementById("submitbutton").addEventListener("click", handleInput, false);
});

section-contact-form.css:

.contact img {
  max-width: 100%;
}

.contact .form__message {
  align-items: flex-start;
}

.contact .icon-success {
  margin-top: 0.2rem;
}

.contact .field {
  margin-bottom: 1.5rem;
}

@media screen and (min-width: 750px) {
  .contact .field {
    margin-bottom: 2rem;
  }
}

.contact__button {
  margin-top: 3rem;
}

@media screen and (min-width: 750px) {
  .contact__button {
    margin-top: 4rem;
  }
}

@media screen and (min-width: 750px) {
  .contact__fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-column-gap: 2rem;
  }
}

 /****************************************** PROGRESS BAR STYLING ******************************************/

.progress {
  margin: 50px auto;
  padding: 0px;
  width: 100%;
  max-width: 500px;
  background: white;
  border: 1px solid #000;
  border-radius: 5px;
  height: 10px;
  overflow: hidden;
}

.progress .progress__bar {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(
    to right, red, orange , yellow, green, cyan, blue, violet);
  transition: 0.3s;
}