Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to show a sub question based on the previous answer

Posted on 2006-06-05
2
Medium Priority
?
177 Views
Last Modified: 2013-12-24
I have a form, with a bunch of includes.  Two of the includes, <cfinclude template="../../items/survey/surveyA260.html"> and <cfinclude template="../../items/survey/surveyA108.html"> have sub questions based on how they answered these questions.  If someone answers yes to <cfinclude template="../../items/survey/surveyA260.html"> , I need to include <cfinclude template="../../items/survey/surveyA109.html"> and again if someone answers yes to <cfinclude template="../../items/survey/surveyA108.html"> , I need to include <cfinclude template="../../items/survey/surveyA109.html">.  
Any help would be appreciated.  The yes/no are radio buttons.  Here is the code to this page


<!--- Set to 2 if testing the formatting. Set to 1 if testing the database. Set to 0 if live. --->
<cfset isDev = 0>
<!---set the starting display number for the questions for this page --->
<cfset displayNumber = 7>
<!--- What page is this? If it is the last page, put 99 --->
<cfset page_number = 2>
<!--- Page they should go to after this page is submitted --->
<cfset post_submit = "../teacher/teacherPre_3.cfm">
<!--- Itemset number --->
<cfset itemset_id = 3>

<!--- PROGRAMMER'S VARIABLES --->
<!--- This is where the data is processed after the submit button is pressed --->
<cfset data_handler = "../cfc_surveys/saveTeacherSurvey.cfc">
<!--- This is where the data is stored in the database --->
<cfset data_base = "aptvre">
<cfset response_table = "itemresponse_t">
<!--- Link after the survey is complete --->
<cfset send_address = "http://www.bc.edu/efeevaluation">
<!--- Description of the link --->
<cfset send_page = "eLearning for Educators Evaluation Study Page">
<!--- If we are live, teacher_id is setting dynamically, if in development, set manually --->
<cfif isDev gte 1>
<!--- This code runs when we are testing the page --->
<cfset teacher_id = 9999>
<cfelse>
<cfif IsDefined("URL.teacher_id")>
<!--- This code runs when it is live --->
<cfset teacher_id = URL.teacher_id>
<!--- Student ID is required --->
<cfparam name="URL.teacher_id" type="numeric" default="0">
<cfelse>
<cfoutput>
<cflocation url="lost_id.cfm">
</cfoutput>
</cfif>
</cfif>

<!--- if this student has finished this testlet, kick him out to home page, no survey page will be shown. --->
<cfquery datasource="#data_base#" name="checkYourStatus">
      SELECT yourItemsetStatus FROM takingatest_t
      WHERE teacherID = #teacher_id# AND itemsetID = #itemset_id#
</cfquery>
<cfif isDev lt 2>
  <cfquery datasource="#data_base#" name="checkYourStatus">
SELECT yourItemsetStatus FROM takingatest_t WHERE teacherID = #teacher_id# AND
itemsetID = #itemset_id#
  </cfquery>  <cfif checkYourStatus.yourItemsetStatus eq 99>
    <cflocation url="code99.cfm?teacher_id=#teacher_id#" addtoken="no">
    <cfabort>
    <!--- If your page is LTE go to the next page --->
    <cfelseif checkYourStatus.yourItemsetStatus GTE #page_number#>
    <!--- It ain't sexy but it works without knowing the addresses --->
<cflocation url="#post_submit#?teacher_id=#teacher_id#" addtoken="no">
    <cfabort>
  </cfif>
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>EFE Teacher Survey</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="../../styles/intasc_form.css" />
<!--[if IE 6]>
<link href="../../styles/intasc_ieform.css" rel="stylesheet" type="text/css" media="screen"  />
<![endif]-->
</link>
</head>
<body>
<center>
  <div id="survey">
     <div id="logo"><a href="http://www.bc.edu/efeevaluation"><img src="../images/efe_surveylogo.gif" alt="intasc" width="87" height="54" border="0" /></a></div>
    <p class="subsection">Teacher Workshop Pre-Survey <br />
      Page 2 of 5 </p>
   
      
    <!--- NOTE: THE FORM FEILD NAMES FOR NOT REAL ITEMS, DO NOT USE SURVEY FOR PART OF FIELD NAMES. SURVEY IS RESERVED FOR FIELD NAMES OF THE REAL ITEMS. ALSO _REQUIRED IS KEYWORD FOR FORM VALIDATION, DO NOT USE FOR OTHER PURPOSES --->
    <form action="<cfoutput>#data_handler#</cfoutput>" method="post" name="surveyForm" class="box1" id="surveyForm" >
      <!--- server side check of the data after the form is submitted but before coldfusion processes the data --->
      <input type="hidden" name="teacherID_required" value="You need to log in before taking this survey.">
     
        <!---begin numbered items --->
      <div class="qnum"><cfoutput>#displayNumber#</cfoutput>.</div>
      <cfinclude template="../../items/survey/surveyA260.html">
      <cfinclude template="../../items/survey/sA261_A262.html">

        <cfset displayNumber = #displayNumber#+1>
      <div class="qnum"><cfoutput>#displayNumber#</cfoutput>.</div>
      <cfinclude template="../../items/survey/surveyA108.html">
        <cfinclude template="../../items/survey/surveyA109.html">

        <cfset displayNumber = #displayNumber#+1>
      <div class="qnum"><cfoutput>#displayNumber#</cfoutput>.</div>
      <cfinclude template="../../items/survey/surveyA263.html">
        
        <cfset displayNumber = #displayNumber#+1>
      <div class="qnum"><cfoutput>#displayNumber#</cfoutput>.</div>
      <cfinclude template="../../items/survey/surveyA264.html">
      
      
        <cfset displayNumber = #displayNumber#+1>
      <div class="qnum"><cfoutput>#displayNumber#</cfoutput>.</div>
      <cfinclude template="../../items/survey/surveyA265.html">
        
      <!--- end of items --->
      <p>&nbsp;</p>
      <p>
        <input type="submit" value="SUBMIT Your Answers" />
      </p>
 <input type="hidden" name="teacherID" value="<cfoutput>#teacher_id#</cfoutput>" />
        <input type="hidden" name="itemsetID" value="<cfoutput>#itemset_id#</cfoutput>" />
         <input type="hidden" name="pageNum" value="<cfoutput>#page_number#</cfoutput>" />
         <input type="hidden" name="dataBase" value="<cfoutput>#data_base#</cfoutput>" />
        <input type="hidden" name="responseTable" value="<cfoutput>#response_table#</cfoutput>" />
        <input type="hidden" name="postsubmit" value="<cfoutput>#post_submit#</cfoutput>" />
      <input type="hidden" name="sendpage" value="<cfoutput>#send_page#</cfoutput>" />       
      <input type="hidden" name="sendaddress" value="<cfoutput>#send_address#</cfoutput>" />
    </form>
  </div>
</center>
</body>
</html>
0
Comment
Question by:nmarano
2 Comments
 
LVL 7

Accepted Solution

by:
ExpertAdmin earned 2000 total points
ID: 16833331
When the page is submitted with the selected answers, check the values to determine which includes to return. For example:

<cfif form.Q1 EQ 1 OR form.Q2 EQ 1>
        <cfinclude template="../../items/survey/surveyA109.html">
</cfif>

Of course, this will have to be included on the return trip to the browser since their answer has to be submitted for CF to evaluate their answer.

Does this help?
0
 
LVL 2

Author Comment

by:nmarano
ID: 16833738
Yes this does help

Thanks
Nick
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
What You Need to Know when Searching for a Webhost Provider
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question