Ask a Question related to Macromedia ColdFusion, Design and Development.
-
phil ashby #1
cfform & cfformgroup
Hi Guys and Gals,
here's the situation. I've got a questionnaire to build and the client wants
it broken down by categories. The questionnaire is dynamic and the database is
structured with each question linked to a category, so the data would look
comething like this.
Category1 - question1
Category1 - question2
Category2 - question1
Category2 - question2
Category2 - question3
Category3 - question1
Category3 - question2
Category3 - question3...etc
I'm trying to use CFFORM and use the tab navigator, creating a tab for each
category as it loops through the recordset and adding the questions in as I
go...code attached
The problem is that I can only close the "page" group once I know that I have
moved onto a new category...but CF won't let me close the group within an CFIF
because at that point in the code it hasn't been opened (although processing
the page logically says that it has!?)
Any ideas?
Cheers
Phil:confused;
<!-- initiative a copy of variables to use in the loop -->
<cfset current_title = "">
<cfset qcounter = 1>
<!-- start the form -->
<cfform name="form1" method="post" action="" format="flash">
<!-- select the tab type grouping -->
<cfformgroup type="tabnavigator">
<!-- initiate the loop -->
<cfloop query="Recordset1">
<!-- if the current category is different from existing, create a new page
in the tab group and update current_title var. -->
<cfif recordset1.category neq current_title>
<!-- close the previous page group THIS IS THE PROBLEM !!!-->
<cfif qcounter gt 1>
</cfformgroup>
</cfif>
<cfformgroup type="page" label="#recordset1.category#">
<cfset current_title = #recordset1.category#>
</cfif>
<!-- now display the question in a horizontal group-->
<cfformgroup type="horizontal" label="#recordset1.question#">
<cfinput type="radio" name="q#qcounter#" label="poor" value="1"
validate="range" range="1,5" >
<cfinput type="radio" name="q#qcounter#" label="fair" value="2"
validate="range" range="1,5">
<cfinput type="radio" name="q#qcounter#" label="ok" value="3"
validate="range" range="1,5">
<cfinput type="radio" name="q#qcounter#" label="good" value="4"
validate="range" range="1,5">
<cfinput type="radio" name="q#qcounter#" label="great" value="5"
validate="range" range="1,5">
</cfformgroup>
<!--update the question counter and loop -->
<cfset qcounter = qcounter+1>
</cfloop>
<!-- close the final page group -->
</cfformgroup>
<cfinput type="submit" name="Submit" value="Submit">
<!-- close the tab group -->
</cfformgroup>
</cfform>
phil ashby Guest
-
Multiple cfformgroup Accordion don't display in IE7Multiple cfformgroup Accordion don't display in IE 7
Sorry for the double post, wasn't sure which category to post this question in. On FireFox 2.0.0.12 (Linux), the attach code displays two... -
cfformgroup question
Below is the snip that I'm using to get my Flash form. I would like a second column with items like address, city, state, zip, company, etc. I keep... -
Background color with cfform/cfformgroup
I have a cfform with cfformgroup tabnavigator. My body tag css sets page background color to blue. I have set the style in cfform (skin is set... -
CFFormGroup Tag
I was going to try yo use the <cfformgroup></cfformgroup> but does not exist. I have Coldfusion MX 7 and Dreamweaver MX 2004 and can not find this... -
Problems with cfformgroup
I have two snippets of code, one using tabs and the over trying to layout a form. The tab example displays the fine while the second example only... -
phil ashby #2
Re: cfform & cfformgroup
Hi all,
sorted it. I did it in two passes, extracting the data for the categories
then embedding the questions query in the loop...attached is code
<cfquery name="Recordset2" datasource="op_audit">
SELECT * FROM dbo.Categories ORDER BY Category_id ASC
</cfquery>
<cfset qcounter = 1>
<cfform name ="myform" format="flash">
<cfformgroup type="tabnavigator">
<cfloop query="recordset2">
<cfformgroup type="page" label="#recordset2.category#">
<cfquery name="questions" datasource="op_audit">
select * from questions where category_ref = #recordset2.category_id# order by
question_id ASC
</cfquery>
<cfloop query="questions">
<cfformgroup type= "horizontal" label ="Q#qcounter#-#questions.question#" >
<cfinput type="radio" name="q#qcounter#" value="0" label="0" checked="yes">
<cfinput type="radio" name="q#qcounter#" value="1" label="1" checked="no">
<cfinput type="radio" name="q#qcounter#" value="2" label="2" checked="no" >
<cfinput type="radio" name="q#qcounter#" value="3" label="3" checked="no">
<cfinput type="radio" name="q#qcounter#" value="4" label="4" checked="no">
<cfinput type="radio" name="q#qcounter#" value="5" label="5" checked="no">
<cfset qcounter = qcounter + 1>
</cfformgroup>
</cfloop>
</cfformgroup>
</cfloop>
</cfformgroup>
<cfinput type="submit" name="Submit" value="Submit">
</cfform>
phil ashby Guest



Reply With Quote

