Results 1 to 2 of 2

Thread: Temp name in javascript

  1. #1
    Join Date
    Aug 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Temp name in javascript

    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
    PHP Code:
    myChart.setDataURL("results.xml"
    and I tried by
    Code:
    myChart.setDataURL("$mytempname")
    But It's not working can any one tell me how to solve this situation please.
    Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If your script is inline on a PHP page:

    PHP Code:
    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:

    HTML Code:
    <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:

    HTML Code:
    <script type="text/javascript" src="chart.php"></script>
    AND you need to put this as the very first line in it:

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

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •