O
O
Oposum2020-05-19 08:02:54
JavaScript
Oposum, 2020-05-19 08:02:54

How to set a time interval, at the end of which, it will be possible to press the button and move on?

The essence of the problem is as follows:
There is a button by which the new user goes to the "Passing the survey" page. After the transition and answers, return and changes on this page are possible only after a certain time after the previous answers on the page.
For example, I clicked the "Continue" button, went to the "Questionnaire" page, filled it out and was redirected to another page. Now I can see the "Questionnaire" page and change something only 1 hour after the previous filling of the Questionnaire.
Actually a question - How to set time and what method?
Thanks in advance for your reply and your time spent on me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Khegay, 2020-05-19
@Oposum

Method 1 (like this):
Use localStorage or sessionStorage , store a datetime variable in it and check this variable inside the application, for example, when a button is pressed.
Method 2 (also so-so):
You need to store datetime in the database, on the server and add a worker that will compare the time and add a webhook - which will send changes to the application.
Again, these methods are redundant. If the user can change the profile only in the session, the easiest way is to store a local variable and hang the event.

A
Anton Shvets, 2020-05-19
@Xuxicheta


For example, I clicked the "Continue" button, went to the "Questionnaire" page, filled it out and was redirected to another page.

Do you send some data to the back, according to a completed questionnaire, for example?
Add filling time there.
Now I can see the "Questionnaire" page, and change something, only after 1 hour

And when you open the questionnaire again, you probably get data on the completed questionnaire from the back.
Together with them, get the time and set the clock, i.e. setTimeout or timer for this filling time plus one hour, the timer has worked, you can remove the disable from the button.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question