title: CF Component Doesn't Reset Variables
body: <p>I have some forms and there is a table with "instructions" for each question, for each form. I am trying to add a button which pops a modal displaying each question's instruction. The problem is every button links to the instruction for the first question. The later instructions exist - If I start w/question 2, everything after that shows Q2's instruction. It's as if it gets locked onto the first field and can't discard it. </p>
  
  <p>Here is the component code:</p>
  
  <pre><code>&lt;cfcomponent displayname="QxQ" output="false" hint="Gets QxQ information for display on data entry screen"&gt;
  
  &lt;cfparam name="qxq_instruct" default=""&gt;
  &lt;cfparam name="qxq_fieldGUID" default=""&gt;
  
  &lt;cffunction name="getFieldInstructions" hint="Gets the QxQ Instructions for the requesting field"&gt;
  
      &lt;cfargument name="qxq_versionGUID" type="string" required="yes"&gt;
  
      &lt;cfargument name="qxq_fieldName" type="string" required="yes"&gt;
  
      &lt;!--- Get FieldGUID based on form VersionGUID and field name ---&gt;
      &lt;cfquery name="qryGetqxqfieldGUID" datasource="#application.DSN#"&gt;
          SELECT
              FieldGUID
          FROM
              _sysformFields
          WHERE
              VersionGUID = &lt;cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#qxq_versionGUID#"&gt;
          AND
              FieldName = &lt;cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#qxq_fieldName#"&gt;
      &lt;/cfquery&gt;
  
  
      &lt;cfset qxq_fieldGUID = #qryGetqxqfieldGUID.FieldGUID#&gt;
  
      &lt;!--- Get instructions based on fieldGUID ---&gt;
      &lt;cfquery name="qryGetFieldInstructions" datasource="#application.DSN#"&gt;
          SELECT
              instruct
          FROM
              _sysFormFieldInstructions
          WHERE
             fieldGUID = &lt;cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#qxq_fieldGUID#"&gt;
      &lt;/cfquery&gt;
  
      &lt;cfif qryGetFieldInstructions.recordcount eq 1&gt;
          &lt;cfset qxq_instruct = #qryGetFieldInstructions.instruct#&gt;
      &lt;/cfif&gt;
  
      &lt;cfset modalButton = '
          &lt;!--- Modal Button ---&gt;
          &lt;button type="button" class="btn btn-small" style="background-color: transparent; border: none" data-toggle="modal" data-target="##exampleModal"&gt;
              &lt;i class="fa fa-question-circle-o fa-2x" style="color: ##8a0d25"&gt;&lt;/i&gt;
          &lt;/button&gt;
  
          &lt;!--- Modal ---&gt;
          &lt;div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt;
              &lt;div class="modal-dialog" role="document"&gt;
                  &lt;div class="modal-content"&gt;
                      &lt;div class="modal-header"&gt;
                          &lt;h5 class="modal-title" id="exampleModalLabel"&gt;Modal title&lt;/h5&gt;
                          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                              &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                          &lt;/button&gt;
                      &lt;/div&gt;
                      &lt;div class="modal-body"&gt;
                          &lt;span style="text-align: left"&gt;
                              #qxq_versionGUID#&lt;br&gt;
                              #qxq_fieldName#&lt;br&gt;
                              #qxq_fieldGUID#&lt;br&gt;&lt;br&gt;
  
                              #qxq_instruct#
                          &lt;/span&gt;
  
                      &lt;/div&gt;
                      &lt;div class="modal-footer"&gt;
                          &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;Close&lt;/button&gt;
                      &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      '&gt;
  
      &lt;cfreturn modalButton&gt;
  
  &lt;/cffunction&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is how I am trying to implement it. This is 2 questions, and should display the instructions for each question. Instead, both buttons display the information for Q1.</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;label class="col-sm-1 control-label"&gt;1.&lt;/label&gt;
    &lt;label for="oftndrink" class="col-sm-10 control-label" style="text-align:left"&gt;
      How often do you have a drink containing alcohol?
    &lt;/label&gt;
    &lt;br&gt;
    &lt;cfset form.qxq=createobject("component","#application.componentspath#.cfc_QxQ")&gt;
    &lt;label class="col-sm-1"&gt;
          #form.qxq.getFieldInstructions(qxq_versionGUID="#formInfo.versionGUID#",qxq_fieldName="oftndrink")#
    &lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>(Q2)</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;label class="col-sm-1 control-label"&gt;2.&lt;/label&gt;
    &lt;label for="numdrinks" class="col-sm-10 control-label" style="text-align:left"&gt;
      How many drinks containing alcohol do you have on a typical day when you are drinking?
    &lt;/label&gt;
    &lt;br&gt;
    &lt;cfset form.qxq=createobject("component","#application.componentspath#.cfc_QxQ")&gt;
    &lt;label class="col-sm-1"&gt;
          #form.qxq.getFieldInstructions(qxq_versionGUID="#formInfo.versionGUID#",qxq_fieldName="numdrinks")#
    &lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks for pointing out the answer, which turned out to be really easy!
  I am now initializing the component in a pre-process that runs once:</p>
  
  <pre><code>&lt;cfset form.qxq=createobject("component","#application.componentspath#.cfc_QxQ")&gt;
  </code></pre>
  
  <p>And can add the modal with the correct instructions by inserting just one line. (This part is a big deal because I have to add it to every question on about 150 forms)</p>
  
  <pre><code>&lt;span style="text-align: left"&gt;#form.qxq.getFieldInstructions(qxq_versionGUID="#formInfo.versionGUID#",qxq_fieldName="varName")#&lt;/span&gt;
  </code></pre>