View Full Version : php code in java script
vmihai
09-12-2002, 02:33 PM
I can declare a variable in java script like follow:
var query;
query ='<?php echo "Java variable =value"?>';
ok !
I want to insert a Java variable into the php script like follow:
var myVar;
myVar =10;
var query;
query ='<?php echo "Java variable =myVar"?>';
----->> result: Java variable =10
is possible ?
I'll appreciate any example!
hryan
09-12-2002, 04:49 PM
query ='<?php echo "Java variable =myVar" ; ?>';
vmihai
09-13-2002, 06:43 AM
the line you indicated is not working, php reject it!
Spookster
09-13-2002, 01:29 PM
PHP and Javascript do not work together. PHP is processed on the server and Javascript is processed in the client-side browser. If you want to send values to php then you will need to send it via a server request either a get or post request.
hryan
09-16-2002, 06:17 PM
Take a look at your first post:
query ='<?php echo "Java variable =myVar" ; ?>';
will give you as result
query =Java variable =myVar_VALUE
I really do not understand whoat you want to do! And are you asking for Java or JavaScript?
If you want to insert a Javascript variable into the php script You can post variable_value like hiddenfield in form or attach it to URL poining to PHPscript.file like
file.php?myvar=myvar_value
And PHP will work with your variable.
Is that you are asking for?
:o
vmihai
09-17-2002, 06:36 AM
Yes hyran is what I want. I reffered to Java Script but I forgot to write it exactly as is.
Thanks for your specifications.
d2kagw
01-15-2003, 02:34 AM
how would you go about flipping that,
as in,
make a javascript variable equal to a php variable?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.