RE: [PHP] Using php to get javascript varibles

From: Date: Wed, 14 Mar 2001 18:54:54 +0000
Subject: RE: [PHP] Using php to get javascript varibles
Groups: php.general 
Request: Send a blank email to php-general+get-43894@lists.php.net to get a copy of this message
1. Do an "echo" in the JS function definition: function myJavascriptFunction() { var foo = <?php echo $somePhpVariable ?>; } 2. Assign the PHP variable to a HIDDEN <FORM> element, then access this from JS: <INPUT TYPE="HIDDEN" NAME="somePhpVariable" VALUE="<?php echo $somePhpVariable ?>"> function myJavascriptFunction () { var foo = document.forms[0].somePhpVariable.value; } Kirk -----Original Message----- I'm in the need to fetch some javascript varibles from php, any ideas on how this could be done ? Regards, Morten Hansen

« previous php.general (#43894) next »