Jump to content

Read Javascript value into PHP variable?


vikinggirl***

Recommended Posts

Hi all
I want to get a value using javascript and read it into a php variable.
I am not sure how this is done.

The value I want to get is the Current Document Height

I then want to read that value into a php variable called $current_height.

(After I've got the value in php, I'll write an easy  if ... then statement based on the value. )

I think the javascript for getting current document height is

[CODE]

expression(document.all.getElementByID('left-sidebar').style.height

[/CODE]

Or something like that. Cannot check until I know how to read it into a variable anyway.

Please can you help me with the syntax for reading this javascript into the variable?

Best
Jo
Link to comment
https://forums.phpfreaks.com/topic/28557-read-javascript-value-into-php-variable/
Share on other sites

Bearing in mind that javascript is running on the client and PHP runs on the server, the easiest way is to put the js value into the value of a hidden form field so it gets submitted with the rest of the form data.
Because Javascript runs on the client and php on the server, you'd need to submit the data to a new php page. This could be done a few ways, but the neatest would probably be to use a little ajax trickery.

[url=http://marc.theaimsgroup.com/?l=php-general&m=112198633625636&w=2]Here[/url] is a simple tutorial written by the creator of php himself.

Hope it helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.