Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
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…
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

722 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