root/trunk/website/soundings/handlers/truefalse/edit.cfm @ 5

Revision 5, 3.0 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/truefalse/edit.cfm
4        Author       : Raymond Camden
5        Created      : September 17, 2004
6        Last Updated : October 7, 2005
7        History      : try/catch
8        Purpose          : Supports True/False, Yes/No
9--->
10
11<cfparam name="attributes.yesno" default="false">
12
13<cfif isDefined("attributes.question")>
14        <cfparam name="form.question" default="#attributes.question.question#">
15        <cfparam name="form.rank" default="#attributes.question.rank#">
16        <cfparam name="form.required" default="#attributes.question.required#">
17<cfelse>
18        <cfparam name="form.question" default="">
19        <cfparam name="form.rank" default="#attributes.toprank+1#">
20        <cfparam name="form.required" default="false">
21</cfif>
22
23<cfif isDefined("form.save")>
24        <cfset form = request.udf.cleanStruct(form)>
25        <cfset errors = "">
26
27        <cfif not len(form.question)>
28                <cfset errors = errors & "You must enter a question.<br>">
29        </cfif>
30       
31        <cfif form.rank is "" or not isNumeric(form.rank) or form.rank lte 0>
32                <cfset errors = errors & "Rank must be 1 or above.<br>">
33        </cfif>
34               
35        <cfif not len(errors)>
36                <cftry>
37                        <cfif not isDefined("attributes.question")>
38                                <cfset application.question.addQuestion(form.question, form.rank, form.required, attributes.surveyidfk, attributes.questionType.id)>
39                        <cfelse>
40                                <cfset application.question.updateQuestion(attributes.question.id,form.question, form.rank, form.required, attributes.surveyidfk, attributes.questiontype.id)>
41                        </cfif>
42                        <cfset msg = "Your question has been saved.">
43                        <cflocation url="questions.cfm?surveyidfk=#attributes.surveyidfk#&msg=#urlEncodedFormat(msg)#" addToken="false">
44                        <cfcatch>
45                                <cfset errors = cfcatch.message>
46                        </cfcatch>
47                </cftry>
48
49        </cfif>
50       
51</cfif>
52
53<cfoutput>
54
55<cfif attributes.yesno>
56        <p>
57        Please use the form below to edit the Yes/No question. You only need to enter the question and the rank.
58        </p>
59<cfelse>
60        <p>
61        Please use the form below to edit the True/False question. You only need to enter the question and the rank.
62        </p>
63</cfif>
64
65<p>
66<cfif isDefined("errors")><ul><b>#errors#</b></ul></cfif>
67<form action="#cgi.script_name#?#attributes.queryString#" method="post">
68<table cellspacing=0 cellpadding=5 class="adminEditTable" width="100%">
69        <tr valign="top">
70                <td width="200"><b>(*) Question:</b></td>
71                <td><input type="text" name="question" value="#form.question#" size="50"></td>
72        </tr>
73        <tr valign="top">
74                <td><b>(*) Rank:</b></td>
75                <td><input type="text" name="rank" value="#form.rank#" size="2"></td>
76        </tr>
77        <tr valign="top">
78                <td><b>(*) Required:</b></td>
79                <td>
80                        <input type="radio" name="required" value="true" <cfif form.required>checked</cfif>>Yes<br>     
81                        <input type="radio" name="required" value="false" <cfif not form.required>checked</cfif>>No<br>
82                </td>
83        </tr>
84
85        <tr>
86                <td>&nbsp;</td>
87                <td><input type="submit" name="save" value="Save"> <input type="submit" name="cancel" value="Cancel"></td>
88        </tr>
89</table>
90</form>
91</p>
92
93</cfoutput>
94
95<cfsetting enablecfoutputonly=false>
96
97<cfexit method="exittag">
Note: See TracBrowser for help on using the browser.