1. Tech

Your suggestion is on its way!

An email with a link to:

http://javascript.about.com/library/blideas.htm

was emailed to:

Thanks for sharing About.com with others!

Ideas Machine

Get Ideas on

Painting

Are you creating web pages about your chosen topic where you want your visitors to take an action? Maybe they aren't performing the action because they need an idea to base their action on and they can't think of one. You can solve that problem by adding an "ideas machine" to your web page where you present them with a randomly selected idea to get them started. If the first idea you give them doesn't help then they can press a button to get another idea.

Here's an example where the action you want them to perform is to paint a painting.

The code for this script is rather simple. To start with you need to copy the content of the following form into a separate file called ideas.js.

The next thing you need to do is to change the content at the top to be your own list of ideas. Each needs to start with ' (apostrophe) and end with ', (apostrophe comma) except for the last one which must not have the comma on the end. You can put whatever text you want in each but if you need an apostrophe inside your text you must precede it with a \ (backslash). You can have as many entries as you like.

Now all we need to do is to add the script to our web page. We need to add two pieces of code to our page for this script. The following needs to be added to the head of the page.

<script type="text/javascript" src="ideas.js"></script>

The final step is to add the following into the body of our page where we want the idea to appear.

<div id="ideas"></div>

We can also style the content of the ideas that are generated however we like by applying styles to the #ideas or #idea elements within our page. For example I have used:

<style>
#ideas {width:250px; margin: 0 auto; font-weight:bold;}
</style>
See More About

©2014 About.com. All rights reserved.