I once made a form build that could be used for pretty much anything,
profiles, questionnaires, anything that required a form.
It was constructed something like thus:-
Table: questions
questionID int primarykey
Question varchar
Fieldtype varchar
Required bit default(0)
Size int
Maxlength int
Validation varchar
Multiple bit default(0)
Table: answers
answerID int primarykey
questionId int
Answer
Table: Options
optionID int primarykey
Optiontext varchar
Optionvalue varchar
DefaultSelected BIT default(0)
So then you just loop over the questions, creating the specifield form field
types with the specified attributes.
For select lists, multi radios or checkboxes, you just add items to the
options table.
E.G.
<cfquery name="questions">
Select * from questions
</cfquery>
<cfquery name="options">
Select * from questions
</cfquery>
<cfloop query="questions">
<cfset QUID = questionID>
<cfif fieldtype="select">
<select name="Q#QID#" #IIF(multiple, "'multiple'", "''")# size="#size#">
<cfloop query="options">
<cfif questionID = QID>
<option value="#optionvalue#" #IIF(SefaultSelected,
"'Selected'","''")#>#optiontext#
</cfif>
</cfloop>
</select>
<cfelseif fieldtype is "text">
<input type="text" name="Q#QID#" maxlength="#maxlength#" size="#size#">#
</cfif>
Get the idea?
Then when the form is submitted you simply save the answers in the answers
table for the specified QID.
--
Russ
-----Original Message-----
From: Dave Francis [mailto:[EMAIL PROTECTED]
Sent: 02 January 2006 15:43
To: CF-Talk
Subject: RE: Best Approach for Survey Question
ALWAYS use separate columns. I've been bit in the a$$ just about
every time I tried the comma-delim list approach.
Another plus is it's really easy to return an Excel file directly to
those doing the tabulating - which they seem to like - without bugging me
for the "latest results" 3 times a day.
-----Original Message-----
From: Richard Colman [mailto:[EMAIL PROTECTED]
Sent: Sunday, January 01, 2006 9:14 PM
To: CF-Talk
Subject: Best Approach for Survey Question
I am trying to determine the best way to structure a series of survey
questions, keeping in mind that I need to make it easy to use for the
respondent, easy to code, and easy to tabulate the data later on.
I can structure the following typical question as a single set of
checkboxes:
Q5: Please select schools that provide interns (check all that apply): [ ]
Sciences [ ] Management/Business [ ] Law [ ] Communications [ ] Other
Using a single datafield for the question, I then would need to parse a
comma-delimited list to separated the answers.
- or - I can use a series of radio buttons:
Q5:Please select schools that provide interns (check all that apply):
A. Sciences [ ]
B. Management/Business [ ]
C. Law [ ]
D. Communications [ ]
E. Other [ ]
If I use a separate data field (5 in this case) for each sub-part of the
question, then it is easy to tabulate results for each part.
Recommendations appreciated.
Richard Colman
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:228138
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54