Jump to content

[SOLVED] Need help passing php vairable to javascript array


bplogan

Recommended Posts

Need help passing php vairable to javascript array.  I have three php variables. $one, $two, and $three.  They each contain text.  I need to get these variables into a javascript array.  This is what I am trying below, but the array does not get these values.  Any help would be appreciated.   

 

 

var fcontent=new Array();

 

fcontent[0]= <?php print $one; ?>;

fcontent[1]= <?php print $two; ?>;

fcontent[2]= <?php print $three; ?>;

Thanks for the reply, but it didn't work.  When the page loads, I get the "done but with errors" exclamation mark in the IE window.  If I just put text for each of the array items, it works.  Here is more code:

 

<script type="text/javascript">


var delay = 2000;
var maxsteps=30; 
var stepdelay=40; 

var startcolor= new Array(255,255,255); 
var endcolor=new Array(0,0,0); 

var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 5px;">';
fcontent[0]= <?php echo $one; ?>;
fcontent[1]= <?php echo $two; ?>;
fcontent[2]= <?php echo $three; ?>;
closetag='</div>';

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.