:: Forum >>

using java variable insibe php

Hello,

I'm trying to use a variable from java inside php.
This is my code:

<?php $heigth = "<SCRIPT language=JavaScript>document.write(parseInt(screen.height))</SCRIPT>";
echo "<table height=$heigth width = 700 border = 1>";
echo "<tr>";
echo "<td>Test</td>";
echo "</tr>";
echo "</table>";
?>


Now this is my result on a Webbrowser:

1024 width = 700 border = 1>
Test

Also when i try to do $heigth = $heigth +2 it returns 2 instead of 1026.

It is driving me crazy.

What am I doing wrong?

Best regards,
Jeppen
Jeppen
Friday, February 22, 2008
Jeppen,

The expected output of the code you have given is actually this:

document.write(parseInt(screen.height)) width = 700 border = 1> Test

since the javascript will only execute once getting to the browser. Furthermore, the result of the javascript is not going to be available to php since by then the page has left the server.

The following posts can give you the info you require:
http://www.activewidgets.com/javascript.forum.4257.37/javascript-and-php-variables.html

http://codingforums.com/archive/index.php?t-72820.html
Alex Ndungu
Saturday, February 23, 2008

This topic is archived.


Back to support forum

Forum search