Results 1 to 2 of 2
  1. #1
    butsags is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Smile Javascript change image

    Hey guys!

    ok so i found this open sources js coding that will simply randomly choose 1 image out of a whatever is given

    so i made it pretty much give a table tag, a background.

    pretty simple. check it out:

    PHP Code:
    // JavaScript Document
    <!--
    function random_imglink(){
      var myimages=new Array()
      myimages[1]="images/marble1.jpg"
      myimages[2]="images/marble2.jpg"
      myimages[3]="images/marble3.jpg"
      myimages[4]="images/marble4.jpg"
      myimages[5]="images/marble5.jpg"
      myimages[6]="images/marble6.jpg"
      myimages[7]="images/marble7.jpg"
      myimages[8]="images/marble8.jpg"
      myimages[9]="images/marble9.jpg"
      myimages[10]="images/marble10.jpg"
    
      var ry=Math.floor(Math.random()*myimages.length)
    
      if (ry==0)
         ry=1
         document.write('<table id="mainbody" style="background: #FFC url('+myimages[ry]+') top left;">')
    }
    random_imglink()
    //-->
    So what I would like to do is make a few simple links like:
    PHP Code:
    <a href=""><img src="icon.gif"></a>
    and then what i would like to have happen is when you click the link/image, it changes the <table> background to one of the images like myimages[1]

    and then ill have the same setup for myimage[2]

    so ill have an array of little icons that each one will change the table background to a given image.

    but of course keeping the randomly choosing a background image each time the page loads.




    do you guys have any ideas on how this would be possible?

    thanks guys :)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. how to change windows xp background image through java
    By erosenthil in forum Advanced Java
    Replies: 1
    Last Post: 08-18-2009, 12:57 PM
  2. Replies: 14
    Last Post: 04-10-2009, 08:46 AM
  3. javascript
    By fiero in forum New To Java
    Replies: 1
    Last Post: 09-22-2008, 01:45 PM
  4. Replies: 0
    Last Post: 01-08-2008, 05:29 PM
  5. Jsp and javascript
    By Ed in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-04-2007, 04:54 AM

Posting Permissions

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