Maybe I'm staring at this too long. I'm trying to pass the screen width, obtained from Javascript screen.width, into a PHP variable. The results don't make any sense: (1) $REZ echos correctly but (2) $wyde never gets changed based on the value of $REZ. I'm running this from an 800x600 screen. For other sizes, change 800 to 1024 etc.
Somebody clue me in on what's going on here.
Bob from Las Vegas
<HTML><HEAD>
<?php $REZ = "<script language=javascript>
document.write(screen.width); </script>" ; ?>
</HEAD><BODY>
<?php
$wyde = "UNCHANGED!" ;
if( $REZ == 800 ) $wyde = "changed to Numeric 800";
if( $REZ == "800" ) $wyde = "changed to Alpha 800";
echo "REZ=" . $REZ . "! and variable is " . $wyde;;
?>
</BODY></HTML>
Passing Javascript variables to PHP
Moderator: General Moderators
cross-post: viewtopic.php?t=6475
Well, I'm a PHP newbie, but a JS pro... how does this work...
A note - screen.width returns an integer value, not a string.
Hope this helps.
Code: Select all
<HTML>
<HEAD>
<script language="JavaScript" type="text/javascript">
<?php
$REZ = ?>
screen.width;
<? ; ?>
</script>
</HEAD>
<BODY>
<?php
$wyde = "UNCHANGED!" ;
if( $REZ == 800 ) $wyde = "changed to Numeric 800";
if( $REZ == "800" ) $wyde = "changed to Alpha 800";
echo "REZ=" . $REZ . "! and variable is " . $wyde;;
?>
</BODY>
</HTML>Hope this helps.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Please don't cross-post, it just gets confusing trying to follow a thread.
If you would like to help please go here:
viewtopic.php?t=6475
Mac
If you would like to help please go here:
viewtopic.php?t=6475
Mac