cfform & cfformgroup

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139