Friday, October 9, 2009

how to pass php value to javascript?

Try this example: test.php

$test = 5;
echo 'OUTPUT: php_test='.$test;
<script type="text/javascript">
= 3;
var test='<?php echo $test;?>';

"js_test=" + test);
//alert("I am an alert box!");


OUTPUT: php_test=5 js_test=5

Eurica !

P.S.: The html tags can be published on blog if convert the code with HTML Encoder

The code should be first encoded with HTML Encoder, after that inserted ;)

You can try with colors also Color Encoder

No comments:

Post a Comment