Jump to content
xisto Community

chireficken

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. Hey All, I'm stuck! I am trying to use PHP variables accessed from an external file in javascript code. I can set the array from the external file. I can get PHP variables to javascript. I can get PHP array variables to javascript. Something goes wrong when I try to move the array variables into javascript. I even tried setting a single variable for just one element of the array and then accessing that single variable in javascript, still no dice. Anyway, here is my code. Any help would be VERY appreciated: <body><?php$cal=(file("test.txt")); // test.txt is just a file with lines 1=day1 info, 2=day2 info etc on separate lines$day5=$cal[4];echo $day5; //successfully echoes '5=day5 info'?><script language="JavaScript" type="text/javascript">document.write("<?php echo $day5 ?>"); //no dice!! Nothing comes out. If I put in a line in the php redefining $day5='this sucks' it works fine</script><?php echo $day5; ?> // just to check that the variable is still accessible during the javascript, and it is</body>
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.