Here's an example of how to do it in javascript:
http://www.webdevelopersnotes.com/tips/html/random_text_display_using_javascript_1.php3
Andy White
2009-04-18 07:01:18
Here's an example of how to do it in javascript:
http://www.webdevelopersnotes.com/tips/html/random_text_display_using_javascript_1.php3
This is how you could write it:
For javascript, simply use the link posted by Andy White and replace the call to Math.floor(7*Math.random())
to a get/set cookie value. You can find ready-to-use javascript functions to read and write cookies on google.
For asp.net mvc, the code won't differ a lot, you just have to look for functions to easily manipulate cookies as they are built-in.
Load your message into an array or some sort of collection that is accessible by index.
Something like (i did not verify all syntax):
string getQuote(){
//Load collection of lines
ArrayList quotes = getQuotesData();
int quoteCount = quotes.Count;
// Set session or application variable to some number
int counter;
if( !Integer.parse( Session("counter"), counter ) ) { counter = 0; }
if( counter > quoteCount ) { counter = 0; }
return quotes[counter];
}
Also, I'm sure something similar is possible in javascript.