Here's the deal:

I'm trying to use 3 buttons to rotate an image on the same page:

BUTTON 1 BUTTON 2 BUTTON 3

<image1, 2, or 3 based on the click.>

DO I need to do this in javascript?

<SCRIPT LANGUAGE="JavaScript">

var images = new Array();
images[0] = new Image();
images[0].src = 'click.jpg';
images[1] = new Image();
images[1].src = 'footballa.jpg';
images[2] = new Image();
images[2].src = 'footballb.jpg';
images[3] = new Image();
images[3].src = 'footballc.jpg'; 

</script>

I'm lost...

    Javascript of course. Php is server side, and so can't redo a page that is already loaded.

    Just use onClick() function.

    First create your images array:

    var myImages = new Array('click.jpg','footballa.jpg','footballb.jpg','footballc.jpg');

    Now write a function that does the image swap:

    function swap(what) {
    document.images['imageName'].src=what;
    }

    Note: You must have an image on the page named imageName, like this:

    <img src='someimage.gif' name="imageName" />

    This is the image that will be swapped each time a button is clicked.

    Now call your function when button is clicked:

    <input type=button onClick="swap(myImages[2])" value="view image">

      Ok, heres what i got:

      in the head:

      <SCRIPT LANGUAGE="JavaScript">
      
      var myImages = new Array('click.jpg','footballa.jpg','footballb.jpg','footballc.jpg');
      
      function swap(what) {
      document.images['imageName'].src=what;
      } 
      
      </script>

      Where the images should rotate:
      <img src='someimage.gif' name="imageName" />

      The first link:
      <input type=button onClick="swap(myImages[2])" value="Class A">

      Does that look right; cause its not working (FIrefox browser)

        Nevermind, i got it. Thanks for your help.

          Write a Reply...