Author Topic: Need coding help, possibly scripts.  (Read 1554 times)

0 Members and 1 Guest are viewing this topic.

Offline Wendell

  • Full Member
  • ***
  • Male
  • Posts: 158
    • http://www.wendell.furtopia.org/
Need coding help, possibly scripts.
« on: June 21, 2005, 12:40:21 am »
Hello there. I have a question that somebody here may be able to answer. I have a main title graphic on my web site.

Wendell's Den main page

I have some alternate images I'm interested in posting in place of that Wendell graphic. They're the same dimensions as the mainpic.jpg, 240x400 pixels. Is there any code, HTML, Java/Javascript, that isn't too complicated but can randomly display in that spot one image from a group? Say I have four images (mainpic1.jpg, mainpic2.jpg, mainpic3.jpg, and mainpic4.jpg) and the web page comes up with a random selection from those four every time the page is accessed?
My HTML skills are passable, but not all that advanced. I know very little Java or Javascript.
-Wendell on FurryMUCK
http://www.wendell.furtopia.org/
FurAffinity: http://www.furaffinity.net/user/wendellsden/
Deviant Art: http://wendellsden.deviantart.com/

Practice your critical skills here! Constructive critiques are welcome and encouraged on any of my drawings posted here. I can take it.

Offline Lavender

  • Sr. Member
  • ****
  • Male
  • Posts: 424
    • The ole furtopia site, desperately needs updating
Need coding help, possibly scripts.
« Reply #1 on: June 25, 2005, 06:38:31 pm »
For some reason a javascript solution doesn't work and belive me I've tried. I think you'll need php and I cannot help you there

Offline renara

  • Newbie
  • *
  • Male
  • Posts: 35
    • http://www.renara.com
Need coding help, possibly scripts.
« Reply #2 on: June 30, 2005, 01:07:10 pm »
Well, this script ought to work, just insert it in place of your image and fill out the variables at the top (they're commented to say what they are).

Code Sample
<script type="text/javascript">
 var path = 'images/front_pictures/'; // Enter the path to your images with trailing slash
 var images = new Array('image1.gif','image2.jpg'); // Enter your image names here

 var number = Math.random();
 var image = images[1 + Math.round(number * (images.length - 1))];

 document.write('<img src="'+path+image+'" alt="" />');
</script>


Hope it doesn't give you too much trouble!





Offline Wendell

  • Full Member
  • ***
  • Male
  • Posts: 158
    • http://www.wendell.furtopia.org/
Need coding help, possibly scripts.
« Reply #3 on: July 04, 2005, 01:15:47 pm »
Thank you so much for the response. I think I can make sense of this.

How does this look?


<script type="text/javascript">
var path = '/';
var images = new Array('mainpic1.jpg','mainpic2.gif','mainpic3.jpg','mainpic4.gif);
var number = Math.random();
var image = images[1 + Math.round(number * 3)];
document.write('<img src="'+path+image+'" BORDER=0 HEIGHT=400 WIDTH=240);
</script>
-Wendell on FurryMUCK
http://www.wendell.furtopia.org/
FurAffinity: http://www.furaffinity.net/user/wendellsden/
Deviant Art: http://wendellsden.deviantart.com/

Practice your critical skills here! Constructive critiques are welcome and encouraged on any of my drawings posted here. I can take it.

Offline Lavender

  • Sr. Member
  • ****
  • Male
  • Posts: 424
    • The ole furtopia site, desperately needs updating
Need coding help, possibly scripts.
« Reply #4 on: July 04, 2005, 04:26:44 pm »
You'll probibly want to stick ALT in there.