Link to home
Start Free TrialLog in
Avatar of nmarano
nmarano

asked on

How to show a sub question based on the previous answer

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>
ASKER CERTIFIED SOLUTION
Avatar of ExpertAdmin
ExpertAdmin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nmarano
nmarano

ASKER

Yes this does help

Thanks
Nick