'Jquery Game-loop Selection Drop-down

Please help, how would you make a timer that runs some code for a time specifed by the user selecting an option from a dropdown menu ? Jquery please. PS: I tried to attach my code but I'm getting errors (here on the stacks) Please help, any ideas welcome. I'm really struggling



Solution 1:[1]

First of all, to set a "timer" in js in general, you use

setTimeout(() => some_stuff, time_in_ms)

for example, to send a console.log in half a second, you'll use

setTimeout(() => {console.log("hi");}, 500);

So, when the user selects the option from the dropdown menu, just start a timer with the delay as what the user chose, and the function as whatever you want to run. If you don't already have a dropdown menu, this tutorial might come in handy to create it: https://www.w3schools.com/howto/howto_js_dropdown.asp

But yea, as the comment mentioned, please also send your code, because without it its really hard to give accurate help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PlainXYZ