Assignment of variables across PHP and JavaScript

From: Date: Fri, 25 Aug 2000 06:51:20 +0000
Subject: Assignment of variables across PHP and JavaScript
Groups: php.general 
Request: Send a blank email to php-general+get-13601@lists.php.net to get a copy of this message
How can we call a javascript function from within a PHP code block? javascript:somefunction(php_vars); gives the syntax errors. "javascript:somefunction(php_vars)"; (enclosing in a pair of quotes) doesn't give the syntax error but does nothing ... doesn't call the function. Cannot call the function outside the PHP code block as I am doing something like, for($i = 0; $i < $tot_num; $i++) { javascript:somefunction(php_vars); } actually I want to pass a double dimensional character array into the javascript function and yesterday itself, I found out that the method to pass PHP variables into JavaScript is via functions as nothing else was working ... for single dimension variables as well. like, <script language = "javascript"> var someVar = <? echo "$anotherVar"; ?> </script> was not working at all. with the help of functions at least I am able to send across the integers and strings (single dimension arrays) but now am stuck up with the sending of double dimensional arrays (array of strings) as the following code which is for passing strings doesn't work the same way for array of strings as well: <script language = "javascript"> function somefunc(aString) { alert(aString); } </script> <!-- HTML code block --> javascript:somefunc(<? echo "$PHP_String"; ?>); <?php *** code *** ?> Do I make sense or have I confused you guys like I am right now? -Ramender Kishore

« previous php.general (#13601) next »