Hi Michael.

Use:
<?php
$text = 'Hello, world!';
?>
<SCRIPT LANGUAGE="JavaScript">
alert( '<?= $text?>' );
</SCRIPT>

If this page is parsed by php i.e. its a .php file rather than .html or .js
file,
then the variable will be output as a string constant in the javascript
code.

Cheers!

Scott
----- Original Message -----
From: "Michael" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 19, 2002 2:54 PM
Subject: [PHP] Passing a PHP variable to javascript


> Hello everyone,
>
> This may seem a newbie question...
>
> I have a PHP variable containing the text of the alert I want to display
> ($text) and I want to have it displayed in a javascript alert box
> (something like alert($text) ).
> I couldn't find out how to sort this out...
>
> Regards,
> Michael
>
>
>
____________________________________________________________________________
__
> Pour mieux recevoir vos emails, utilisez un PC plus performant !
> Découvrez la nouvelle gamme DELL en exclusivité sur i (france)
> http://www.ifrance.com/_reloc/signhdell
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

Reply via email to