RE: [PHP] Calling Javascript-function from php-script ...

From: Date: Tue, 19 Mar 2002 21:11:42 +0000
Subject: RE: [PHP] Calling Javascript-function from php-script ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89214@lists.php.net to get a copy of this message
Not entirely true. Javascript is directly linked to HTML and HTML is directly linked to PHP so you can have PHP talk to Javascript through HTML. So here's a very simple example of a Javascript and PHP script (on separate servers) talking to one other... --------------------------------------------------------------------- <html> <title>myhtmlpage.html</title> <script language=javascript> if (location.search.substring(1)) { // Parse and evalulate the returning GET string. var urlStr = window.location.search.substring(1); var name = urlStr.split('=')[0]; var value = urlStr.split('=')[1]; document.write(value); } else { document.location( "http://www.here.com/myphpscript.php?request=current_time"); } </script> </html> --------------------------------------------------------------------- --------------------------------------------------------------------- <?//myphpscript.php extract($HTTP_GET_VARS); $origin = $HTTP_REFERER; if ($request == ‘current_time’) { $information = time(); // err.. whatever the time function is in PHP header("Location: $origin?return=$information"); } ?> --------------------------------------------------------------------- In this example the Javascript is activated when the page is visited. If no information is being passed in the URL string then it auto-redirects to a PHP script on another server. The PHP script extracts the variables from the GET string and redirects back to the originating script with the requested information. Now when the Javascript reads it it’ll parse out the value and write it to the screen closing the loop. Pretty slick eh? -Kevin -----Original Message----- From: Alexander Skwar [mailto:ASkwar@host.homelinux.org] Sent: Tuesday, March 19, 2002 12:54 PM To: Marcel Besancon Cc: php-general@lists.php.net Subject: Re: [PHP] Calling Javascript-function from php-script ... »Marcel Besancon« sagte am 2002-03-19 um 13:04:38 +0100 : > Hi everybody, > > is there someone who can tell me how to call a javascript-function by a > php-script. PHP creates HTML pages (mostly) which will be displayed by a client and/or receives send pages/requests from a client. There's no connection between the two. Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.iso-top.de | Jabber: askwar@charente.de iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 2 days 8 hours 46 minutes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#89214) next »