Lasso Examples Pack - Quick Poll

This example allows you to place a quick poll on a Web site. The poll can ask one question and has a multiple choice answer. Each site visitor can answer the poll and the results so far will be shown in a pop-up window. You can restrict visitors to voting once or once per hour, day, or month. Once a poll is complete it can be archived and its results will be shown permanently on your site.

The quick poll example demonstrates the following principles:

- How to use JavaScript to display a dynamic element within your site. The example uses a method similar to how some ad placement tools work.

- How to create a simple bar graph in HTML without using the image tags.

- How to use CSS to customize the display of text.

- How to keep track of unique visitors and how to check so they can only vote in the poll in the desired frequency.

The quick poll example can be used as-is to present polls to your site visitors or can be customized with your own CSS and HTML in order to make it fit into your site design better. The quick poll example can also be studied for ideas of how to present dynamic data on your sites, how to create a simple ad delivery system, and how to present data in bar graph form.

This documentation is split into two parts. The first part introduces the poll example and shows how you can use it to display polls on your own Web site without any programming. The second part dissects the example and shows how polls are served, how voters are checked for uniqueness, and how the administration interface is constructed.

Creating and Displaying Quick Polls

Embedding a Poll

Polls are embedded into a Web site using a block of JavaScript code. The visitor's Web browser must support JavaScript in order for the quick poll example to work. Visitors who do not support JavaScript will not see anything in the location of the poll.

The following code is used to embed the "current" poll into a Web site. The "current" poll can be set in the administration interface (see below). Using this code makes it easy to present a new poll question daily or weekly by choosing a different "current" poll. The URL in the "src" attribute must point to the "Display" folder within the quick poll example folder.

<!-- Quick Poll - Current -->
<script src="http://www.example.com/ExamplesPack/display/poll.lasso" type="text/javascript" />
<!-- Quick Poll - End -->

The script block returns an HTML div which is displayed at its location on your page. The div displays just as if it had been written directly into your HTML. The div has self contained CSS rules so that it displays appropriately even if your site uses its own stylesheet.

The "current" poll from the quick poll example is shown below live. By default this will show a poll "What is your favorite color?", but if you have created your own polls already then whichever has been set as the "current" poll will show below.