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; ?>;

Link to comment
Share on other sites

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>';

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.