On my website I have a button that selects a random quote from a list of quotes and projects the randomly selected quote into a text box. This is done using JavaScript.
Although I have this working, I'd like an additional piece of code that will prevent the directly subsequent quote being the same as the previous. I'd like any quote used to be able appear again however, just not directly following.
If possible I'd also like it so any quote used does not appear again for a minimum of another 3 clicks - but this would just be a bonus.
Anyway the code I currently have is as follows:
<head>
<script language="javascript"><!--
function GenerateQuote(){var aquote=new Array;
aquote[0]="\"Quote0\"";
aquote[1]="\"Quote1\"";
aquote[2]="\"Quote2\""
aquote[3]="\"Quote3\"";
aquote[4]="\"Quote4\"";
aquote[5]="\"Quote5\"";
aquote[6]="\"Quote6\"";
rdmQuote=Math.floor(Math.random()*aquote.length);
document.getElementById("quoteBox").value=aquote[rdmQuote];
}
-->
</script>
</head>
<body>
<textarea id="quoteBox" readonly></textarea>
<button onClick="GenerateQuote()">Entertainment & Hobbies</button>
</body>
Thanks in advance; I'm sure it won't be too hard for you brainiacs!