Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 10-31-2006, 05:58 PM   #1 (permalink)
Inactive
 
Join Date: 10-31-06
Posts: 5
iTrader: 0 / 0%
Latest Blog:
None

tuckerkatt is liked by many
Question "Random non-random" image generator

Hi all -

This seems to be a great forum and I'm sure someone here can help me.

I'd like to have a sort-of-random image generator. I have the code for a random image generator, and that's fine, but sometimes I want to show a certain image more than others. I hope I'm explaining this clearly...say I have 11 images, and I want one of them to show up 50% of the time and the other 10 to show up 5% of the time each. I would think this is pretty simple for a good coder, but that ain't me.

Thanks!

tuckerkatt
tuckerkatt is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 10-31-2006, 06:01 PM   #2 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 17,965
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
If you're using the JS code that I've used.... why not just repeat the entry twice?

There IS a way to do it with percentages, but if your random coding is already in place, to reason to repaint the room. Like this:

Code:
<!-- Hide from old browsers var imagenumber = 4 ; var randomnumber = Math.random() ; var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ; images = new Array images[1] = "images/01.jpg" images[2] = "images/02.jpg" images[3] = "images/03.jpg" images[4] = "images/03.jpg" var image = images[rand1] // -- End Hiding Here -->
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
chıcgeeĸ @ flickr
chicgeek is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-31-2006, 06:20 PM   #3 (permalink)
Inactive
 
Join Date: 10-31-06
Posts: 5
iTrader: 0 / 0%
Latest Blog:
None

tuckerkatt is liked by many
Thanks laura, very simple solution. I think that'll work for me.

Thanks again!
tuckerkatt is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wanna a Name for your Business? Use this Random Name Generator!!! olddocks Marketing Forum 15 10-27-2007 09:35 AM
random image script Julie Coding Forum 1 03-06-2006 04:20 PM
"download image" not "open image" Ricoool Coding Forum 13 06-17-2004 09:34 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 03:35 PM.
© Copyright 2008 V7 Inc