J
Jennie Friesen
Hello--
I would like to display a different line of text (32 different
messages) on refresh, BUT with no repeats.
The script I am currently using is:
<script language=javascript type=text/javascript>
<!--
a = Math.floor(Math.random() * 32);
switch (a){
case 0 :
document.write("msg 1 here");
break;
case 1 :
document.write("msg 2 here");
break;
}
// etc., up to 32 cases
//-->
</script>
I notice that many random text scripts use an array to store the text
messages, and was thinking that incorporating a line in the script
where the array value that was most recently accessed would be
deleted, would make its subsequent selection impossible, thereby
solving the no-repeats.
In the script below, can one suggest where the delete line would fit
in and what its syntax would be?
thank you in advance!
JF
<SCRIPT LANGUAGE="Javascript">
// <!--
function text() {
};
text = new text();
number = 0;
// textArray
text[number++] = "Random text string 1."
text[number++] = "Random text string 2."
text[number++] = "Random text string 3."
text[number++] = "Random text string 4."
text[number++] = "Random text string 5."
// keep adding items here...
increment = Math.floor(Math.random() * number);
document.write(text[increment]);
// where does delete text[number++] fit in?
//--></SCRIPT>
I would like to display a different line of text (32 different
messages) on refresh, BUT with no repeats.
The script I am currently using is:
<script language=javascript type=text/javascript>
<!--
a = Math.floor(Math.random() * 32);
switch (a){
case 0 :
document.write("msg 1 here");
break;
case 1 :
document.write("msg 2 here");
break;
}
// etc., up to 32 cases
//-->
</script>
I notice that many random text scripts use an array to store the text
messages, and was thinking that incorporating a line in the script
where the array value that was most recently accessed would be
deleted, would make its subsequent selection impossible, thereby
solving the no-repeats.
In the script below, can one suggest where the delete line would fit
in and what its syntax would be?
thank you in advance!
JF
<SCRIPT LANGUAGE="Javascript">
// <!--
function text() {
};
text = new text();
number = 0;
// textArray
text[number++] = "Random text string 1."
text[number++] = "Random text string 2."
text[number++] = "Random text string 3."
text[number++] = "Random text string 4."
text[number++] = "Random text string 5."
// keep adding items here...
increment = Math.floor(Math.random() * number);
document.write(text[increment]);
// where does delete text[number++] fit in?
//--></SCRIPT>