logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Journals
Folklore and Mythology
Business Coach
Marriage
Senior Living
Ethnic Beauty
Adolescence


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

Fortune Cookie / Random Quote Code - Array
Guest Author - Lisa Shea

It's always fun to have a fortune cookie on your website, to give a random quote or fortune or message each time the visitor comes by. Note that this version does NOT require a database to work.

First, you need to create the array with the quotes or fortunes or whatever you will be showing. The array is a string array, with each array member being a different quote. So you can use -

Dim Quotes(20)
Quotes(1) = 'The black bird will signify danger.'
Quotes(2) = 'Be sure to eat something red today.'

and so on.

Since you defined the array right in your code, you know how big the array is. Use the randomize function to get a random item in the array. How to use the Randomize Function. If you had 20 items in your array, your randomize function would be:

CurrID = Int((19 * Rnd) + 1)

Now you have an ID number somewhere between 1 and the maximum ID in your database. Now all you have to do is select the matching phrase!

CurrPhrase = Quotes(CurrID)

That's it! Now you can show your item_desc to your user and have different fortunes, quotes, phrases or anything else appear each time they come back!

Fortune Cookie Code Using a Database
Sample ASP Code

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.

This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map

Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Twitter Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Facebook Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to MySpace Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Del.icio.us Digg Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Yahoo My Web Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Google Bookmarks Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Stumbleupon Add Fortune+Cookie+%2F+Random+Quote+Code+%2D+Array to Reddit


Content copyright © 2009 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter

jobs
what
job title, keywords
where
city, state or zip
jobs by job search


vote
Growing a Garden
Veggies and Flowers
Veggies Only
Flowers Only
No Garden

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2009 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor