I have a problem, I am trying to save a value when it's changed, also this changes for everyone i.e whoever sees it online. So take this site for example: https://scorecount.com/tennis/ when the click on the 0 it turns 15 but if you refresh the page it turns back to 0, so I want a way using javascript to save this 15 score added and saved until the next value and this change should be visible to everyone. Thanks so much for the help.
Asked
Active
Viewed 316 times
-2
-
You need a database where data will be stored and each time an user loads the page, query the database for the data or even using Ajax, you could load changes in real time. This is basics you should be able to accomplish. StackOverflow helps on specific issues/problems encountered not such broad questions. – esQmo_ Nov 18 '21 at 18:22
-
Please edit your question and add in the code segment related to your question and explain at what point in that code segment, you aren't getting the results you expect. – devlin carnate Nov 18 '21 at 18:22
-
The link I have provided is the site. You can look into its javascript, CSS and html – Kronox Nov 19 '21 at 04:20
-
Also, I am using Django, so I am using sqllite3 database. So is there a way if I can connect this and automatically save it to the database – Kronox Nov 19 '21 at 04:21
1 Answers
-1
You can use localstorage in javascript to set the score.
localStorage.setItem('score', Your score here)
You can retrieve it with
localStorage.getItem('score')
You can clear it with
localStorage.removeItem('score')

Nishanth
- 304
- 3
- 12
-
So with this method everyone visiting the site would be able to see the actual score or they see the initial values? – esQmo_ Nov 18 '21 at 18:37