my problem is that I can not stop a timer.
I had this method to set a timeout from this forum. It supposed to store the identifyer in the global variable. By accid
As written mytimer is a function which never has the value of a timeout identifier, therefore your clearTimeout statement will achieve nothing.
I don't see any recursion here at all, but you need to store the value setTimeout returns you, and if you need to pair this with multiple potential events you need to store it against a key value you can lookup - something like an element id perhaps?