root/trunk/website/soundings/handlers/matrix/display.cfm @ 5

Revision 5, 2.7 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<!---
3        Name         : handlers/matrix/display.cfm
4        Author       : Raymond Camden
5        Created      : October 7, 2005
6        Last Updated : April 10, 2006
7        History      : Wasn't working when you went backwards (rkc 4/10/06)
8        Purpose          : Supports Matrix
9--->
10
11<cfparam name="attributes.question">
12<cfparam name="attributes.r_result" default="result">
13<cfparam name="attributes.answer">
14<cfparam name="attributes.step">
15
16<cfset answers = application.question.getAnswers(attributes.question.id)>      
17
18
19<cfquery name="getAnswers" dbtype="query">
20        select          *
21        from            answers
22        where           rank >= 0
23        order by        rank asc
24</cfquery>
25
26<cfquery name="getItems" dbtype="query">
27        select          *
28        from            answers
29        where           rank < 0
30        order by        rank desc
31</cfquery>
32
33<cfif isDefined("form.submit")>
34        <cfif attributes.question.required>
35                <cfloop query="getItems">
36                        <cfif not structKeyExists(form, "q" & replace(id,"-","_","all"))>
37                                <cfset errors = "You must select an answer for each item.">
38                                <cfbreak>
39                        </cfif>
40                </cfloop>
41        </cfif>
42                               
43        <cfif not isDefined("errors")>
44                <cfset result = structNew()>
45                <cfloop query="getItems">
46                        <cfparam name="form.q#replace(id,"-","_","all")#" default="">
47                        <cfset result[id] = form["q" & replace(id,"-","_","all")]>
48                </cfloop>
49
50                <!--- param for non required results --->
51                <cfset caller[attributes.r_result] = result>
52        </cfif>
53</cfif>
54
55       
56<cfif isDefined("errors")>
57        <cfoutput>
58        <p class="error">#errors#</p>
59        </cfoutput>
60</cfif>
61       
62<cfoutput>
63<p>
64<table>
65        <tr valign="top">
66                <td>#attributes.step#) #attributes.question.question#</td>
67        </tr>
68        <tr valign="top">
69                <td>
70                <table border="1" cellpadding="5">
71                        <tr>
72                                <td>&nbsp;</td>
73                                <cfloop query="getAnswers">
74                                        <td>#answer#</td>
75                                </cfloop>
76                        </tr>
77                        <cfloop query="getItems">
78                                <cfset itemid = id>
79                                <tr>
80                                        <td>#answer#</td>
81                                        <cfloop query="getAnswers">
82                                        <!---<cfset selected = isDefined("form.q#replace(itemid,"-","_","all")#") and form["q" & replace(itemid,"-","_","all")] is id>--->
83                                        <cfset selected = false>
84                                        <cfif (isDefined("form.q#replace(itemid,"-","_","all")#") and form["q" & replace(itemid,"-","_","all")] is id)
85                                                        or
86                                                  (structKeyExists(attributes, "answer") and isStruct(attributes.answer) and structKeyExists(attributes.answer, itemid) and attributes.answer[itemid] is id)
87                                                        >
88                                                <cfset selected = true>
89                                        </cfif>                         
90                                        <td><input type="radio" name="q#replace(itemid,"-","_","all")#" value="#id#" <cfif selected>checked</cfif>></td>
91                                        </cfloop>
92                                </tr>
93                        </cfloop>
94                </table>
95                </td>
96        </tr>
97</table>
98</p>
99</cfoutput>
100                               
101<cfsetting enablecfoutputonly=false>
102
103<cfexit method="exittag">
Note: See TracBrowser for help on using the browser.