Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-28
4
Medium Priority
?
255 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 1500 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

886 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