ldsmike88 Posted April 8, 2006 Share Posted April 8, 2006 I am getting a monitors resolution with JavaScript. After I get the resolution I want to make it a PHP variable. I want to do all of this on one page. How do I do it? JavaScript:[code]<script type="text/javascript"> document.write(screen.width+"x"+screen.height); </script>[/code]If I am going to echo the variable it works like this:[code]$resolution = '<script type="text/javascript"> document.write(screen.width+"x"+screen.height); </script>';[/code]The only problem is I am not going to echo it, I am going to put it in mySQL database. Does anyone know how to pass this variable to php? Thanks!Mike Link to comment https://forums.phpfreaks.com/topic/6859-javascript-to-php/ Share on other sites More sharing options...
kenrbnsn Posted April 8, 2006 Share Posted April 8, 2006 Remember, PHP runs on the server and Javascript runs on the client. PHP is done with all of its processing before Javascript starts to execute. The only way to do what you want is to use AJAX where your Javascript script starts up a small PHP script in the background and passes the information.Ken Link to comment https://forums.phpfreaks.com/topic/6859-javascript-to-php/#findComment-24955 Share on other sites More sharing options...
ldsmike88 Posted April 8, 2006 Author Share Posted April 8, 2006 Hmm... Maybe I'll look into passing it through a cookie. I have been meaning to look that up for a while. Thanks! Link to comment https://forums.phpfreaks.com/topic/6859-javascript-to-php/#findComment-24957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.