Return javascript variable back to Form

Yep, returning data from JS back to Python is certainly possible.

Please read these docs:

In particular, anvil.call() calls back to Python.