Re: Output (Urgent!)
| From: | Sheridan Saint-Michel | Date: | Tue, 17 Jul 2001 15:00:47 +0000 |
| Subject: | Re: Output (Urgent!) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58274@lists.php.net to get a copy of this message | ||
You aren't getting the value to the PHP script... allow me to walk through
what is actually happening
$resolution = "<SCRIPT
LANGUAGE=\"JavaScript\">document.write(screen.width)</SCRIPT>";
echo "--".$resolution."--";
You have just set a variable to "<SCRIPT
LANGUAGE=\"JavaScript\">document.write(screen.width)</SCRIPT>" and then
echoed that string. so it looks like you have
--1024-- or whatever your resolution is. if you view source though you see
you really have
--<SCRIPT LANGUAGE=\"JavaScript\">document.write(screen.width)</SCRIPT>--
and the client browser is just interpreting that JavaScript statement
if (($resolution*1) >= 1024) {
$resolution = "1024";
} else {
$resolution = "800";
}
echo "**".$resolution."**";
The reason this isn't acting the way you expect is because you AREN'T saying
if ((1024*1) >= 1024 {
You are actually saying
if ((<SCRIPT
LANGUAGE=\"JavaScript\">document.write(screen.width)</SCRIPT>*1) >= 1024) {
You are not actually passing anything from JavaScript to PHP... you are just
tricking yourself =)
Sheridan
----- Original Message -----
From: Morten Winkler Jørgensen <madmax@mip.sdu.dk>
To: <php-general@lists.php.net>
Sent: Tuesday, July 17, 2001 4:54 AM
Subject: Re: [PHP] Output (Urgent!)
>
> >> How you want to get a value from client side to php on the same page?
>
> Well. Actually I didn't invent the code. I just correcteded it so it
> worked on my installation. I must admit I was amazed that it somehow
> worked, but it did.
>
>
> Kind regards,
> Morten Winkler