Posts Tagged PHP Variable javascript error
undefined variable error javascript with php
Posted by gullele in jQuery/JavaScript/CSS, PHP on August 1, 2012
you want to do something simple like passing variable like this
<?php $variable_name = "some value"; var some_var = <?=$variable_name" ?>;
but it didn’t work
Here is the solved version…
Very simple than you thought
<pre> $variable_name = "some value"; var some_var = "<?=$variable_name" ?>"; </pre>
yup, just quote it from left and right so that it wont be considered as string not JS variable. If the value in variable is number, there would not be any problem