Solved

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

Posted on 2008-10-28
4
249 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help editing script 3 74
whm high memory usage in processes 7 89
issue with beginner powershell script. 5 62
Disk Ram Peak 1 43
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

803 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