For a nicer way to echo js vars, use the javascript helper.

<?php

$data = array(array(0,0), array(1, 1), array(2, 4));

?>
<script type="text/javascript">
<?php
echo 'var x = '.$javascript->object($data);
?>
</script>

On Nov 8, 12:00 pm, serave <[EMAIL PROTECTED]> wrote:
> `unction Graficador($funcion){
>         $xy = "[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7,
> 49], [8, 64], [9, 81], [10, 100],";
>
> echo"<div id=\"wrapper\">
>         <div id=\"container\" style=\"width:600px;height:300px;\"></div>
>         <pre><code class=\"javascript\">var f = Flotr.draw($('container'),
> [ d1, d2 ]);</code></pre>
> </div>
> <script type=\"text/javascript\">
>
>         document.observe('dom:loaded', function(){
>
>             var d2 = [$xy];
>
>             var f = Flotr.draw($('container'), [  d2 ]);
>         });
> </script>";
>
> ?>
>
> So var d2 should be printed as   var d2 = [[0, 0], [1, 1], [2, 4], [3,
> 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81], [10, 100],];
> which is not happening.
> how can i assign a php variable to a javascript variable?
> I've also tried putting the javascript by itselef and writting
>  var d2 = [<?php echo $xy ?>]; and it doesnot work either please help
> me!!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to