Assign javascript variable to php variable

Assign javascript variable to php variable Marketing. Stack Overflow works best with JavaScript enabled. See this one maybe duplicate? Michel Plungjan We can also follow another approach - The approach is when site is getting loaded send device width what to say in a personal statement assign javascript variable to php variable side using ajax and save it in the database and then fetch where you want to use. We bring ideas to life in the form of clean, elegant websites. It seems like you're misunderstanding. Ashok Kumar Apr 11 '17 at Asked 9 years ago. In this case:? It might me be the solution m not sure Web Dev. PHP runs on the server, JavaScript on the client. But you could pass the JS variable as a URL parameter or something and go to a new page or refresh the current page to get it. Introducing the Moderator Council - and its first, pro-tempore, representatives. The JS variable needs to be defined before you actually use it anywhere. The second your string contains a double quote, it will break. PHP is executed before javascript.