vikinggirl*** Posted November 26, 2006 Share Posted November 26, 2006 Hi allI 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 HeightI 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 More sharing options...
Barand Posted November 26, 2006 Share Posted November 26, 2006 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. Link to comment https://forums.phpfreaks.com/topic/28557-read-javascript-value-into-php-variable/#findComment-130652 Share on other sites More sharing options...
trq Posted November 26, 2006 Share Posted November 26, 2006 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. Link to comment https://forums.phpfreaks.com/topic/28557-read-javascript-value-into-php-variable/#findComment-130654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.