Solved

Code for Simple Polling Question - Single Question w/ 3-4 Optional Answers

Posted on 2008-10-28
4
252 Views
Last Modified: 2013-12-24
Good Morning.
I am searching for the code needed to create a single polling question on an index.cfm page on our site.  It will be a single question with 3 or 4 possible answers.  Something like:  

How often do you visit our site?
- Daily
- Weekly
- Monthly
- Never

Once visitor selects the answer, a new, small window will open and display the results of the current poll.  The polling question and answers will change monthly and we have no need to store past polling results and/or data.  

I have done lots of searching for a simple solution with no luck thus far.  So any help would be greatly appreciated!!
0
Comment
Question by:cindyredo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Expert Comment

by:duncancumming
ID: 22826118
Take a look at Soundings:
http://soundings.riaforge.org/
0
 
LVL 10

Accepted Solution

by:
Mr_Nil earned 500 total points
ID: 22826680
Hi Cindy,

Unfortunately dynamic poll's are never that simple to write and not that easy to post a complete response on somewhere like Experts Exchange.  You will have to fill in the blanks yourself.

For a dynamic poll you're going to need 3 tables in your database.  The first table is a "question" table, the second is an "options" table and the third is "answers".

The question table should look something like this :
QuestionID Int AutoNumber PrimaryKey
QuestionText Text
StartDate DateTime

The option table should look something like this :
OptionID Int AutoNumber PrimaryKey
fkQuestionID Int ForeignKey
OptionText varchar(100)
DisplayOrder int

The Answer Table should look something like this:
AnswerID Int AutoNumber PrimaryKey
fkSelectedOptionID Int ForeignKey

You'll probably want to add some fields to the answer table to record who made that answer and possible help protect against abuse.

You'll need to create some CRUD (Create, Read, Update, Delete) functions to allow you to manage the Question text, its start date and its associated options and order the options so that the display the way you want them to.

You'll need a function to select the question for the current month using the start date and display a form displaying the question and the options as radio buttons. When the form is submitted you'll need to save the selected answer and any information from the user you require.  To display the graph of responses use CFChart and a group by query of the latest question, its options and the count of answers eg.

SELECT Q.QuestionID, Q.QuestionText, O.OptionID, O.OptionText, Count(A.AnswerID) AS AnswerCount
FROM tblQuestion AS Q
INNER JOIN tblOption AS O ON Q.QuestionID = O.fkQuestionID
INNER JOIN tblAnswer AS A ON O.OptionID = A.fkOptionID
WHERE Month(Q.StartDate) = Month(Now()) AND Year(Q.StartDate) = Month(Now())
GROUP BY Q.QuestionID, Q.QuestionText, O.OptionID, O.OptionText
ORDER BY O.DisplayOrder

As I hope I've indicated there is a lot to think about and a lot of code associated with it. Far too much to post and explain on here and it occurs to me....  Why am I when I can simply point you to Ray Camden's Soundings application on RIAForge.org - http://soundings.riaforge.org/  ;)
0
 

Author Comment

by:cindyredo
ID: 22841977
Thank you for your comments.  I was hoping there was a way to accomplish this without having to store data in a database...the server where this site resides does not have SQLServer installed.  What is this Soundings application, I took a look, but did not understand.
0
 
LVL 16

Expert Comment

by:duncancumming
ID: 22844223
hahaha, trying to do a poll without a database is going to be very difficult!  the only real alternative would be to write everything to file every time someone votes in the poll, and read the file(s) to work out what the ongoing scores are at any time.... very far from ideal.

there are other databases of course, many of them free.  you could even try treating something like excel as a datasource.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSL Certificate for IIS7 Site 2 115
Powershell GUI 11 89
Powershell PGP and SFTP 1 47
How to use 2 separate DNS names. 5 54
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question