I wanna make a thing in javascript and html and I've got a problem.
I've a selection page where I can click on 8 different buttons, and I want a var to take the id of this button. This button throw me on an other page, which have to use this var.
The problem is that when the code is called once again in the second page (to return the var in my main function otherwise it's not working), this code is updated and my var is obviously reset to 0;
I want to keep the value of this var when I call it again in my other page.
Thank you !
levelSelected = 0;
// Récupère le click
for (var i = 0; i < 8; i++) {
$('#level' + i).click(function() {
levelSelected = this.id;
console.log(levelSelected);
location.href='level.html';
});
}