Jquery Game-loop Selection Drop-down

34 Views Asked by At

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

1

There are 1 best solutions below

6
PlainXYZ On

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.