Click to See Complete Forum and Search --> : javascript with php problem!..


saipkjai
08-10-2003, 07:40 PM
can PHP variables asoociate with javascript?!?!
since I want to use some php variable in the javascript...

Exuro
08-10-2003, 08:04 PM
You can always do something like this:

<script type="text/javascript">
<!--
var num1 = <?php echo $num1; ?>
//-->
</script>

pyro
08-10-2003, 08:25 PM
Yes, you can use something like what Exuro showed. Moving values from PHP to javascript is fairly easy, as PHP runs serverside and is executed before any javascript code will be displayed, thus transfering variable's values is fairly easy. Going the other way, from javascript to PHP, is a bit harder, and will require a refresh of the page.