Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I mentioned in my earlier comment that the simplest way to do this in ColdFusion was to bind your form elements to cfc methods. A google search on "cfinput bind" will lead to lot's of examples, but since I was asked to provide an answer, I'll show an example I once wrote. It's not exactly what the OP wants, but it shows the general idea. It will populate one text box based on the value of another.</p> <p>Note that the cfc and cfm files have to be in the same directory.</p> <p>.cfm file</p> <pre><code>&lt;!--- When you type a clinic code here: ----&gt; &lt;div id="clinicCodeInput" class="hidden"&gt; Clinic Code &lt;input name="clinicCode" type="text" /&gt; &lt;/div&gt; &lt;!---- A query result will appear here ----&gt; &lt;div id="clinicNameFromPatientSatisfaction" class="hidden"&gt; Patient Satisfaction Name &lt;cfinput type="text" name="NameOfClinic" bind="cfc:PatientSatisfactionClinics.GetClinicName({clinicCode})" bindonload="no"&gt; &lt;/div&gt; </code></pre> <p>.cfc file</p> <pre><code>&lt;cffunction name="GetClinicName" access="remote" returntype="string"&gt; &lt;cfargument name="clinicCode" type="string" required="yes"&gt; &lt;cfscript&gt; var clinicName = QueryNew("a"); var returnString = "No Record for Clinic Code " &amp; arguments.clinicCode &amp; "."; var clinicCodeAsInt = 0; if (isNumeric(arguments.clinicCode) and round(arguments.clinicCode) is arguments.clinicCode) clinicCodeAsInt = arguments.clinicCode; &lt;/cfscript&gt; &lt;cfif clinicCodeAsInt gt 0&gt; &lt;cfquery name="clinicName" datasource="dw"&gt; select name from patient_satisfaction_clinic where clinic_code = &lt;cfqueryparam cfsqltype="cf_sql_integer" value="#clinicCodeAsInt#"&gt; &lt;/cfquery&gt; &lt;cfif clinicName.recordcount gt 0&gt; &lt;cfset returnString = clinicName.name[1]&gt; &lt;/cfif&gt; &lt;/cfif&gt; &lt;!--- clinicCodeAsInt gt 0 ---&gt; &lt;cfreturn returnString&gt; &lt;/cffunction&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload