Kaustubh wrote:
i need all you genius guys help. Well i have databse of quotes in TXT
format i want the javascript which ll radomize that database means
everytime when user come on my page then script ll pick up one
sentence from data base and show it but i want diff sentence at each
visit i have done in ASP i want that in JAVA script please let me have
you guys Help !
I think you can even use SQL to select a random row/record from a data
base table so why do you want to use client-side script to achieve that?
Solve that on the server and there is no problem with clients having
script disabled or not supporting script.
If you really want to use client-side script create an array with the
quotes and use a random index into the array:
<html lang="en">
<head>
<title>random quotes</title>
<script type="text/javascript">
var quotes = [
'Kibology for all.',
'All for Kibology.',
'Kibology rules.'
];
var randomIndex = Math.floor(Math.random() * quotes.length);
var randomQuote = quotes[randomIndex];
</script>
</head>
<body>
<p>
<script type="text/javascript">
document.write(randomQuote);
</script>
</p>
</body>
</html>
--
Martin Honnen
http://JavaScript.FAQTs.com/