RE: [PHP] Assignment of variables across PHP and JavaScript

From: Date: Fri, 25 Aug 2000 07:00:20 +0000
Subject: RE: [PHP] Assignment of variables across PHP and JavaScript
Groups: php.general 
Request: Send a blank email to php-general+get-13607@lists.php.net to get a copy of this message
> Do I make sense or have I confused you guys like I am right now? The impression I get from your email is that you want to call the JavaScript function with PHP. This can't be done because the PHP code is executed on the server, stripped out, and the result is sent to the web browser in the HTML page they originally requested. You can pepper your JavaScript with variables set by PHP at the page load time, but PHP cannot call a JavaScript function - unless we're talking about server side JavaScript which is so rare it's not funny... echo "<SCRIPT LANGUAGE='JavaScript'>\n" ."<!-- \n" ." var somestring = '".$PHP_VARIABLE_HERE."'\n" ."-->\n" ."</SCRIPT>\n"; This should work to set the initial value of a variable when the page is first loaded by the web browser. If you're attempting to pass PHP variables into a JavaScript function and it's just not working, try setting the status bar value to the actual text of the function call, and you should be able to see where you're going wrong. Or alert() it out. Sorry if I've misunderstood you - the sudden influx of JavaScript questions the last couple of days is kind of alarming. Jason

« previous php.general (#13607) next »