This question already has an answer here:

I need to use the value of a JavaScript variable in a module.
For example, I am getting a city = 'delhi' in a JavaScript file, and I need to use this value in a module showing a form.

marked as duplicate by Pierre.Vriens, No Sssweat, Shawn Conn, Clive Mar 13 '16 at 10:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You could send that value to a callback function in your .module file using AJAX, an example to do that stuff in forms see that tutorial Ajaxify form fields

And you could send any value to js variable see sending-a-javascript-variable-to-drupal

Not the answer you're looking for? Browse other questions tagged or ask your own question.