tony wrote:
Hi all,
I got this sets(20) of defined constants which using them as keys to an
array
eg
define("FNAME", "fname");
farray = array( FNAME => "hello" ,...);
my question is how do I insert that directly into a javascript(to do
some client validation)
I need this:
var fname = document.addrform.fname.value
var fname = document.addrform.{FName}.value //don't work
var fname = document.addrform.{'FName'}.value //don't work
var fname = document.addrform.[FName].value //don't work
I know this work, but messey
$tmp = FNAME;
var fname = document.addrform.{$tmp}.value
you could try sprintf()/printf():
$output = sprintf('var fname = document.addrform.%s.value', FNAME );
or
printf('var fname = document.addrform.%s.value', FNAME );
I'am finding the use of define constants rather awkward. does anyone
make much use of them?
yes. :-) for...
session varnames
post/get varnames
bitwise flags
er...?
Thanks
Tony
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php