top of page

Forum Posts

Renzo Iceman
Sep 24, 2022
In Coding with Velo
Hey, I am trying to make a website that has four buttons and tracks how many times each button has been pressed. The problem is that the values are only saved per session, so when you refresh the page all the values are reset to 0. You can only see the button presses in your session and not from other sessions and from other people's sessions.. How do I store the values somewhere so that the total values can always be displayed? Here is my code if that helps: let potatoTotal = 0;let tomatoTotal = 0;let carrotTotal = 0;let cucumberTotal = 0;$w.onReady(function () {$w('#button2').onClick(() => {potatoTotal = potatoTotal + 1;$w('#text9').text = 'Potato: ' + potatoTotal;});$w('#button1').onClick(() => {tomatoTotal = tomatoTotal + 1;$w('#text8').text = 'Tomato: ' + tomatoTotal;});$w('#button3').onClick(() => {carrotTotal = carrotTotal + 1;$w('#text10').text = 'Carrot: ' + carrotTotal;});$w('#button4').onClick(() => {cucumberTotal = cucumberTotal + 1;$w('#text11').text = 'Cucumber: ' + cucumberTotal;});});
0
0
5
Renzo Iceman
Sep 21, 2022
In Coding with Velo
Hey, I am trying to make a website that has four buttons and tracks how many times each button has been pressed. The problem is that the values are only saved per session, so when you refresh the page all the values are reset to 0. You can only see the button presses in your session and not from other sessions and from other people's sessions.. How do I store the values somewhere so that the total values can always be displayed? Here is my code if that helps: let potatoTotal = 0; let tomatoTotal = 0; let carrotTotal = 0; let cucumberTotal = 0; $w.onReady(function () { $w('#button2').onClick(() => { potatoTotal = potatoTotal + 1; $w('#text9').text = 'Potato: ' + potatoTotal; }); $w('#button1').onClick(() => { tomatoTotal = tomatoTotal + 1; $w('#text8').text = 'Tomato: ' + tomatoTotal; }); $w('#button3').onClick(() => { carrotTotal = carrotTotal + 1; $w('#text10').text = 'Carrot: ' + carrotTotal; }); $w('#button4').onClick(() => { cucumberTotal = cucumberTotal + 1; $w('#text11').text = 'Cucumber: ' + cucumberTotal; }); });
1
0
18

Renzo Iceman

More actions
bottom of page