0

I have a progress bar built in JS and bootstrap, the code is bellow

var totalCountries = 10;
var currentCountries = 0;
var $progressbar = $("#progressbar");

$("#next, #next1").on("click", function(){
  if (currentCountries >= totalCountries){ return; }
  currentCountries++;
  $progressbar.css("width", Math.round(100 * currentCountries / totalCountries) + "%");
});

On every button press the bar grows, I would like that when the progress bar reaches 100% to be redirected to anoither page. Any idea how to do that?

LiveDigi
  • 35
  • 1
  • 7
  • 3
    Possible duplicate of [How to redirect to another webpage in JavaScript/jQuery?](http://stackoverflow.com/questions/503093/how-to-redirect-to-another-webpage-in-javascript-jquery) – forgivenson May 04 '17 at 17:30

1 Answers1

0

When your currentCountries equals your totalCountries you can just do a redirect.

$("#next, #next1").on("click", function(){
  currentCountries++;
  $progressbar.css("width", Math.round(100 * currentCountries / totalCountries) + "%");

  if (currentCountries >= totalCountries){ 
    window.location = "http://www.yoururl.com";
  }
});
nicholaswmin
  • 21,686
  • 15
  • 91
  • 167