PHP & Javascript

PHP & Javascript

am 18.04.2007 15:05:28 von Alf C Stockton

Please suggest a way to pass the value contained in a PHP variable to
Javascript.
I have $ID with a certain value in PHP and want to do a Javascript
window.location="Another.php?UID="+2;
and replace the above hardcoded 2 with the value in $ID.

--
Regards,
Alf Stockton www.stockton.co.za

This night methinks is but the daylight sick.
-- William Shakespeare, "The Merchant of Venice"
My email disclaimer is available at www.stockton.co.za/disclaimer.html

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: PHP & Javascript

am 18.04.2007 15:09:34 von Bill Bolte

Google is your friend:
http://www.google.com/search?sourceid=3Dnavclient-ff&ie=3DUT F-8&rls=3DGGG=
L,GGG
L:2006-19,GGGL:en&q=3Djavascript+querystring=20

-----Original Message-----
From: Alf Stockton [mailto:alf@stockton.co.za]=20
Sent: Wednesday, April 18, 2007 8:05 AM
To: php windows
Subject: [PHP-WIN] PHP & Javascript

Please suggest a way to pass the value contained in a PHP variable to=20
Javascript.
I have $ID with a certain value in PHP and want to do a Javascript=20
window.location=3D"Another.php?UID=3D"+2;
and replace the above hardcoded 2 with the value in $ID.

--=20
Regards,
Alf Stockton www.stockton.co.za

This night methinks is but the daylight sick.
-- William Shakespeare, "The Merchant of Venice"
My email disclaimer is available at www.stockton.co.za/disclaimer.html

--=20
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP & Javascript

am 18.04.2007 17:00:54 von php

Google! is your friend, but I acutally enjoy typing. :)

Do something like this:



or something like that. :)
You know, PHP parses before the browser gets to do JavaScript stuff, so
when the browser gets the code, it'll say UID=2 ... or what ever
variable you've got stored in $thevariablecontainingthenumbertwo.

Mike


Alf Stockton skrev:
> Please suggest a way to pass the value contained in a PHP variable to
> Javascript.
> I have $ID with a certain value in PHP and want to do a Javascript
> window.location="Another.php?UID="+2;
> and replace the above hardcoded 2 with the value in $ID.
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP & Javascript

am 18.04.2007 17:17:19 von Alf C Stockton

Mikael Grön wrote:
> Google! is your friend, but I acutally enjoy typing. :)
>
> Do something like this:
>
>
>
> or something like that. :)
> You know, PHP parses before the browser gets to do JavaScript stuff, so
> when the browser gets the code, it'll say UID=2 ... or what ever
> variable you've got stored in $thevariablecontainingthenumbertwo.
>
Thank you Mikael.
One of my problems is getting my mind around what happens on the client
and what happens on the server. Even though I knew that PHP parses on
the server and the result of that is sent to the client where javascript
operates the solution you suggest never entered my mind.
I'll know better next time and thank you again.


--
Regards,
Alf Stockton www.stockton.co.za

She is not refined. She is not unrefined. She keeps a parrot.
-- Mark Twain
My email disclaimer is available at www.stockton.co.za/disclaimer.html

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP & Javascript

am 18.04.2007 17:24:30 von Aleksandar Vojnovic

And don't forget to add
$thevariablecontainingthenumbertwo =
intval($thevariablecontainingthenumbertwo);
or stripslashes

Mikael Grön wrote:
> Google! is your friend, but I acutally enjoy typing. :)
>
> Do something like this:
>
>
>
> or something like that. :)
> You know, PHP parses before the browser gets to do JavaScript stuff,
> so when the browser gets the code, it'll say UID=2 ... or what ever
> variable you've got stored in $thevariablecontainingthenumbertwo.
>
> Mike
>
>
> Alf Stockton skrev:
>> Please suggest a way to pass the value contained in a PHP variable to
>> Javascript.
>> I have $ID with a certain value in PHP and want to do a Javascript
>> window.location="Another.php?UID="+2;
>> and replace the above hardcoded 2 with the value in $ID.
>>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP & Javascript

am 19.04.2007 03:36:39 von bedul

fyi your talk about simple javascript using PHP??
that's a lame..

u need to upgrade your skill for using AJAX

actualy google is your friend.. but what u want anyway.. u must to describe
the case not some talking like above
----- Original Message -----
From: "Mikael Grön"
To: "php windows"
Sent: Wednesday, April 18, 2007 10:00 PM
Subject: Re: [PHP-WIN] PHP & Javascript


> Google! is your friend, but I acutally enjoy typing. :)
>
> Do something like this:
>
>
>
> or something like that. :)
> You know, PHP parses before the browser gets to do JavaScript stuff, so
> when the browser gets the code, it'll say UID=2 ... or what ever
> variable you've got stored in $thevariablecontainingthenumbertwo.
>
> Mike
>
>
> Alf Stockton skrev:
> > Please suggest a way to pass the value contained in a PHP variable to
> > Javascript.
this line is very weird.. pass value from PHP to JS is easy.. u need to
beware about wrong statement.
but pass value from JS to PHP is a tricky things
> > I have $ID with a certain value in PHP and want to do a Javascript
> > window.location="Another.php?UID="+2;
> > and replace the above hardcoded 2 with the value in $ID.
u need AJAX.. u might try search on YAHOO-AJAX (i don't quited remember the
name.)

well it only work "well" on ie actualy.. but if you able to customize well..
opera, mozilla and soon able to accept your script.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP & Javascript

am 19.04.2007 10:08:49 von php

Yes, of course.

Though, the security part of this should be in 'another.php' and focused
on handling the incoming var from $_GET['UID']...
On the JavaScript side of things, nothing but the client browser is
vulnerable anyway.

Mike


Aleksandar Vojnovic skrev:
> And don't forget to add
> $thevariablecontainingthenumbertwo =
> intval($thevariablecontainingthenumbertwo);
> or stripslashes
>
> Mikael Grön wrote:
>> Google! is your friend, but I acutally enjoy typing. :)
>>
>> Do something like this:
>>
>>
>>
>> or something like that. :)
>> You know, PHP parses before the browser gets to do JavaScript stuff,
>> so when the browser gets the code, it'll say UID=2 ... or what ever
>> variable you've got stored in $thevariablecontainingthenumbertwo.
>>
>> Mike
>>
>>
>> Alf Stockton skrev:
>>> Please suggest a way to pass the value contained in a PHP variable
>>> to Javascript.
>>> I have $ID with a certain value in PHP and want to do a Javascript
>>> window.location="Another.php?UID="+2;
>>> and replace the above hardcoded 2 with the value in $ID.
>>>
>>
>
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php