mardi 24 février 2015

Is it possible to add weight to images in a generator?

Firstly, I would like to thank you for taking time out of your day for clicking on this post. :)


Ok, so I am bored and wish to make a random image generator (which is working fine), however, I was wondering is there a way to add weight to certain images which won't appear as much as others?


I have attached the code below:



<script language="JavaScript">

function random_imglink(){
var myimages=new Array()

myimages[1]="Blue_Car.png"
myimages[2]="Red_Car.png"
myimages[3]="White_Car.png"
myimages[4]="Black_Car.png"


var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=0>')
}
random_imglink()


function confirmRefresh() {
var okToRefresh = confirm("Do you really want to refresh the page?");
if (okToRefresh)
{
setTimeout("location.reload(true);",10);
}
}

</script>
<input type="button" value="Generate a new player" onClick="document.location.reload(true)">


</script>
</a></p>


I do have a SMALL amount of knowledge regarding JavaScript, however, I'm no pro.


I would like to thank everyone who helps me.


Also may I add, there will be an incentive for someone who can help me get this done! Thank you!





Aucun commentaire:

Enregistrer un commentaire