Ideas Machine With Optional Links

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.

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 bottom to be your own list of ideas. Each needs to start with { and end with }, except for the last one which must not have the comma on the end. Each entry should have some text to display identified using txt:'...' (where ... represents the text for that option with \ in front of any apostrophes) and optionally lnk:'...' to provide a destination that the text is to link to. Where a lnk value is supplied it can come either before or ater the txt value but they must have a comma between to separate them. You can have as many entries as you like. There are a few examples included at the bottom of the script that you should replace with your own.

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 bottom of the page just before the </body> tag.

<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 #ideasP or #ideas elements within our page. For example I have used:

#ideas {width:250px; margin: 0 auto; font-weight:bold;}


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow