Obi1-Cannabis Posted April 4, 2007 Share Posted April 4, 2007 Is it possible to pass a php variable into a js variable without the use of post get or ajax?i thought maybe something like: <? print"<script language=JavaScript>";print"var jsVar= '".$phpVar."';";print"</script>";?> I think it actually does work, but it keeps giving me errors that don't have anything to do with this variable but that don't appear when i'm not using that variable... Link to comment Share on other sites More sharing options...
jesh Posted April 4, 2007 Share Posted April 4, 2007 You might want to post this in the PHP forum (or do a search there because I swear someone has recently asked this very question there). Link to comment Share on other sites More sharing options...
msd Posted April 8, 2007 Share Posted April 8, 2007 <?$phpVar = "php to js";print "<script type=\"text/javascript\">\n";print "var jsVar = '".$phpVar."';\n";print "alert(jsVar);\n";print "</script>";?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now