Connecting Tech Pros Worldwide Forums | Help | Site Map

How to Pass PHP variables to JS?

Don
Guest
 
Posts: n/a
#1: Jul 17 '05
How do I pass PHP variables to JavaScript in the returned browser page?

Thanks,
Don

David Zawislak
Guest
 
Posts: n/a
#2: Jul 17 '05

re: How to Pass PHP variables to JS?


Don wrote:
[color=blue]
> How do I pass PHP variables to JavaScript in the returned browser page?
>
> Thanks,
> Don[/color]
Well, you could do this if you have a variable $_POST['name']:
....
some javascript
.....

echo 'var name = ' . $_POST['name'];

....
Just like HTML, but you write valid javascript.
Don
Guest
 
Posts: n/a
#3: Jul 17 '05

re: How to Pass PHP variables to JS?


On Mon, 08 Nov 2004 14:04:37 -0600, David Zawislak <davez0411@excite.com> wrote:
[color=blue]
>Don wrote:
>[color=green]
>> How do I pass PHP variables to JavaScript in the returned browser page?
>>
>> Thanks,
>> Don[/color]
>Well, you could do this if you have a variable $_POST['name']:
>...
>some javascript
>....
>
>echo 'var name = ' . $_POST['name'];
>
>...
>Just like HTML, but you write valid javascript.[/color]

Thanks David. That worked just fine.

Regards,
Don


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jeremy Smith
Guest
 
Posts: n/a
#4: Jul 17 '05

re: How to Pass PHP variables to JS?


Don wrote:[color=blue]
> How do I pass PHP variables to JavaScript in the returned browser page?
>
> Thanks,
> Don[/color]

<?
$hello = "hello";
?>

<script language="javascript">
alert("<?=$hello;?>");
</script>
Warren Oates
Guest
 
Posts: n/a
#5: Jul 17 '05

re: How to Pass PHP variables to JS?


In article <1100189674./W3ZIuK13gf7EpV3ROowxg@teranews>,
Jeremy Smith <di99smje@chl.chalmers.se> wrote:

:<script language="javascript">
:alert("<?=$hello;?>");
:</script>

Or (something useful):

<?php
$referred_to = 'http://127.0.0.1/~you/old_browser.php';
?>

<script language="Javascript" type="text/javascript">
if (!document.getElementById) {
top.location.replace("<?php echo $referred_to; ?>");
}
</script>
--
Looks like more of Texas to me.
.... Arizona, where the nights are warm and the roads are straight.
Don
Guest
 
Posts: n/a
#6: Jul 17 '05

re: How to Pass PHP variables to JS?


On Thu, 11 Nov 2004 17:14:31 +0100, Jeremy Smith <di99smje@chl.chalmers.se> wrote:
[color=blue]
>Don wrote:[color=green]
>> How do I pass PHP variables to JavaScript in the returned browser page?
>>
>> Thanks,
>> Don[/color]
>
><?
>$hello = "hello";
>?>
>
><script language="javascript">
>alert("<?=$hello;?>");
></script>[/color]
Thanks Jeremy.
Don


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Don
Guest
 
Posts: n/a
#7: Jul 17 '05

re: How to Pass PHP variables to JS?


On Thu, 11 Nov 2004 11:45:39 -0500, Warren Oates <Warren.Oates@Gmail.com> wrote:
[color=blue]
>In article <1100189674./W3ZIuK13gf7EpV3ROowxg@teranews>,
> Jeremy Smith <di99smje@chl.chalmers.se> wrote:
>
>:<script language="javascript">
>:alert("<?=$hello;?>");
>:</script>
>
>Or (something useful):
>
><?php
>$referred_to = 'http://127.0.0.1/~you/old_browser.php';
>?>
>
><script language="Javascript" type="text/javascript">
>if (!document.getElementById) {
>top.location.replace("<?php echo $referred_to; ?>");
>}
></script>[/color]
Thanks Warren.
Don


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Closed Thread