Does anyone have a script, that can display a random image of the images I select?I'm going to use it for a type of captcha. I think this would be easier in javascript, so yes I am in the right section.
Does anyone have a script, that can display a random image of the images I select?I'm going to use it for a type of captcha. I think this would be easier in javascript, so yes I am in the right section.
Clarification please ...
Where are the images coming from?
How are you getting the "images I select?"
Does the random display occur only once when page is loaded?
Do you have any sample starting code to show position, layouot, etc.?
sorry, I want the images from a url, I just paste the url into the source code as src="URL" yes only once per load, no, I don't have any sample codes...they're from my forum.
<img id = "captchaImage" width = "150" height = "150" >
<script type = "text/javascript">
var imgArray = ['One.gif','Two.gif','Three.gif','Four.gif','Five.gif', 'Six.gif', 'Seven.gif', 'Eight.gif', 'Nine.gif'];
function randOrd(){return (Math.round(Math.random())-0.5)}
imgArray.sort(randOrd);
alert (imgArray); // FOR TESTING
var len = imgArray.length;
var count = 0;
function rotate() {
document.getElementById("captchaImage").src = imgArray[count];
count++;
if (count>=len) {count = 0}
var tcaptchaImage = window.setTimeout("rotate()", 5000); // 5 seconds
}
rotate();
</script>
If you want to use URLs for the images, simply make your imageArray a list of the relevent URLs. If one image only is to be shown at page load then obviously the rotate() function is redundant. All you need is
document.getElementById("captchaImage").src = imgArray[0];
Quizmaster: What is the meaning of the French expression "coup de grâce"?
Contestant: Lawnmower.