View Full Version : Temp name in javascript

01-25-2011, 02:45 PM
Presently I am a working on a chart. So I need to generate xml fles and use it for chart. But my problem is I have to declare the xml file name inside javascript. I have made tempname format with php by byt I amunable to put php variable insode the script. the script will look like


and I tried by

But It's not working can any one tell me how to solve this situation please.

01-26-2011, 02:14 PM
If your script is inline on a PHP page:

myChart.setDataURL("<?php echo $mytempname; ?>");

Even if it's not, you would use the same syntax, but let's say your script is called chart.js and you use a tag like:

<script type="text/javascript" src="chart.js"></script>

to get it onto your page. Then you need to rename it to chart.php and call it like so to your page:

<script type="text/javascript" src="chart.php"></script>

AND you need to put this as the very first line in it:

<?php header('Content-type: text/javascript'); ?>