Reply to Re: PHP activating JAVASCRIPT?

Your name:

Reply:


Posted by Kim Andrι Akerψ on 04/12/07 18:31

kick ass wrote:

> Hello
>
> My problem is:
> I have one JAVASCRIPT inside <head> of my HTML.
> I want PHP code which is written inside the <body> of my HTML to
> activate it.
>
> Here is the sample code that works (but I dont want to use ONLOAD
> command ):
>
> <head>
> <title>Untitled Document</title>
> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
> function sayhello (text) {
> alert(text);
> }
> </SCRIPT>
> </head>
>
> <body onload="javascript:sayhello('SOME_TEXT')">
>
> </body>
>
> -------------------------------------------------------------------
>
>
> <head>
> <title>Untitled Document</title>
> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
> function sayhello (text) {
> alert(text);
> }
> </SCRIPT>
> </head>
>
> <body> <!-- I DONT WANT TO USE onLoad HERE-->
> <?php
>
> ---now here i want to activate that javascript above but using
> php code.... IS IT POSSIBLE SOMEHOW TO CALL THAT FUNCTION???--- ?>
>
> </body>
>
> THANKS FOR ANY HELP!!

As Steve said, PHP is run server-side (on the server), while JavaScript
is run client-side (in the user's browser), so to call a JavaScript
function, you'll have to let PHP output some JavaScript code, like this:

<?php
echo "<script type='text/javascript'>sayhello('SOME_TEXT');</script>";
?>

And please refrain from TYPING EVERYTHING IN UPPERCASE!!!!!!!!!(!!!!)
It makes you "sound" like you're yelling/screaming most of the time.

--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация