Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Converting Javascript to PHP

    Hello, is it possible to convert this piece of Javascript to PHP?

    Code:
    var thisPic = [0, 0, 0, 0, 0];
    function chgSlide(change, direction)
    	{
    	if(document.images)
    		{
    		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]];
    		}
    	}

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.

  • #3
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.

  • #6
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. I was just wondering if it was possible for PHP to do it. Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •