Jump to content

JavaScript to PHP


ldsmike88

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.