View Full Version : Converting Javascript to PHP

10-21-2004, 09:05 AM
Hello, is it possible to convert this piece of Javascript to PHP?

var thisPic = [0, 0, 0, 0, 0];
function chgSlide(change, direction)
thisPic[change] += direction;
imgCt = (imageChoice[change].length -1 && altChoice[change].length -1);
if(thisPic[change] > imgCt)
thisPic[change] = 0;
if(thisPic[change] < 0)
thisPic[change] = imgCt;
document.getElementById(slideID[change]).src = imageChoice[change][thisPic[change]];
document.getElementById(slideID[change]).alt = altChoice[change][thisPic[change]];

10-21-2004, 10:53 AM
I'm not a huge javascripter, however that appears to be a dynamic image generator correct? Which would mean that the browser doesn't need to be reloaded between each object. Answer: No, javascript is a dynamic-like browser altering language, php is a static data display language. If it something to reload an image, something could be done, otherwise, I would look at flash as being your other good option.

10-28-2004, 04:02 AM
Actually, I'm not quire sure what a dynamic image generator is. It's javascript for image swap.

Here's a link: http://ampulator.freeprohost.com/zgundam.html

Check around the Methuss.

10-28-2004, 04:11 AM
Just like what fou-lu said.

You could writ it in php if you wanted, but you'd have to reload the page everytime the image was going to change, which would be annoying. Leave it as javascript

10-29-2004, 08:12 AM
Yes, javascript is your best bet for swapping. PHP cannot handle such a function, so if you have it working, its perfect leave it be. If your looking for a way to specify what images there are, ordering techniques, mime types etc, then php can help you in conjuntion with your current javascript there.

10-31-2004, 09:34 PM
Thanks. I was just wondering if it was possible for PHP to do it. Thanks!