Using values from PHP in JavaScript -


i use value php in javascript, it's not working. fetch data database , store in php variable , conditional formatting. need use data in javascript validation.

the value required me $date = date('y-m-d'); if pass value json encode alert function not working...

$(document).ready(function() { alert("hi"); var array = php print(json_encode($date));  }); 

whereas if alert function without...

var array = php print(json_encode($date)); ; 

...it works fine.

<script type="text/javascript" src="assests/js/jquery-1.10.2.js"></script> <script type="text/javascript"> $(document).ready(function() { alert("hi"); var array = '<?php print(json_encode($date)); ?>'; }); </script> </head> <body> <form action="majorprocess.php"> <?php $dbconn = mysql_connect('localhost', 'root','' ); if(!$dbconn) { die(mysql_error()); } else { $date = date('y-m-d'); 

<script type="text/javascript" src="assests/js/jquery-1.10.2.js"></script> <script type="text/javascript"> $(document).ready(function() {     alert("<?php echo json_encode(date('y-m-d')); ?>"); }); </script> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -