L
lharby
I'm hoping this is very simple. I am currently using a random quote
generator on our intranet.
I have 17 quotes, when I add in an 18th and change the makeArray
number the code seems not to work.
This works:
<script LANGUAGE="JavaScript">
function makeArray(len) {
for (var i = 0; i < len; i++) this = null;
this.length = len;
}
quotes = new makeArray(17); //This Number is a variable relating to
the Number of Quotes//
quotes[0] = "\"Imagination is more important than knowledge \" Albert
Einstein";
quotes[1] = "\"One should always play fairly when one has the winning
cards. \" Oscar Wilde"; ...............
.............
quotes[16] = "\"Well, if I called the wrong number, why did you answer
the phone? \" James Thurber";
function rand(n) {
seed = (0x015a4e35 * seed) % 0x7fffffff;
return (seed >> 16) % n;
}
var now = new Date()
var seed = now.getTime() % 0xffffffff
</script>
<script LANGUAGE="JavaScript">
var quoterand = quotes[rand(quotes.length)];
if (quoterand.length < 40) {
document.write(quoterand+"")
} else { document.write(quoterand)
}
</script>
All I od is add another quote, increase the makeArray and it goes
wrong. Any ideas?
TIA
Luke
generator on our intranet.
I have 17 quotes, when I add in an 18th and change the makeArray
number the code seems not to work.
This works:
<script LANGUAGE="JavaScript">
function makeArray(len) {
for (var i = 0; i < len; i++) this = null;
this.length = len;
}
quotes = new makeArray(17); //This Number is a variable relating to
the Number of Quotes//
quotes[0] = "\"Imagination is more important than knowledge \" Albert
Einstein";
quotes[1] = "\"One should always play fairly when one has the winning
cards. \" Oscar Wilde"; ...............
.............
quotes[16] = "\"Well, if I called the wrong number, why did you answer
the phone? \" James Thurber";
function rand(n) {
seed = (0x015a4e35 * seed) % 0x7fffffff;
return (seed >> 16) % n;
}
var now = new Date()
var seed = now.getTime() % 0xffffffff
</script>
<script LANGUAGE="JavaScript">
var quoterand = quotes[rand(quotes.length)];
if (quoterand.length < 40) {
document.write(quoterand+"")
} else { document.write(quoterand)
}
</script>
All I od is add another quote, increase the makeArray and it goes
wrong. Any ideas?
TIA
Luke