Garayed.com  

Go Back   Garayed.com > PHP
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-2006, 10:57 PM
Garry Jones
 
Posts: n/a
Default php within javascript

For a photo display I am using a javascript I found on the net (freeware).
The Java script code has to be placed within head and /head tags

The Java code consists of the start

<script language="JavaScript1.2">

Then about 150 lines of script followed by values I have to write in

and then about another 150 lines of Java script before the
</script>

The values I have to write in are the names of the files in this format

Pic[0] = 'img/2005/horiz/image0.jpg'
Pic[1] = 'img/2005/horiz/image1.jpg'
Pic[2] = 'img/2005/horiz/image2.jpg'
Pic[3] = 'img/2005/horiz/image3.jpg'

I have placed these in a php file and I use Include from the middle of the
java script to call these in. It works fine for these four files

As I have 3600 lines to write I would like to use a php echo to write the
lines into the java script. Something along the lines of

<?
i=0;
While ($i<3601){
echo "Pic[";
echo $i;
echo"] = 'img/2005/horiz/image";
echo $i;
echo ".jpg'";
i++;
}
?>

But it does not work and I have played around with the syntax and tried
varying methods. Is this because Java script does not like too much php code
and its conflicting. Or should I be able to use php code freely from within
the Java script and I have simply created a php syntax error.

The page fails to load. Checking the source code in MSIE reveals that it
stops working in the middle of the Java when it comes to the php code.

Any help appreciated.

A footnote to this is that I wonder what php++ does to the number "0" if it
is written "0000", would the "++" method give an output of 0001 or 1?

Garry Jones
Sweden







Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:18 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.