Skip to main content
Inspiring
January 24, 2013
Question

I want to use the user's input to parameterize a query in the same cfm file

  • January 24, 2013
  • 1 reply
  • 539 views

Is there any way to use the a cfinput value entered at the top of a form in a cfquery as a where clause value?  I am trying to create a dynamically generated table of checkboxes based on what is returned for a single SSN from the database.

My query so far is:

 

<cfquery name="PatientDiagnoses" datasource="ccta">
      SELECT
Diagnoses.DiagnosisID,

                    Diagnoses.Diagnosis,

                    "Selected" = CASE WHEN Diagnoses.DiagnosisID IN
                               (SELECT ReferringDiagnosis.DiagnosisID

                FROM ReferringDiagnosis
                     WHERE SSN = '#FORM.SSN#')
      FROM Diagnoses
      ORDER BY Diagnosis
</cfquery>

But of course FORM.SSN which is the cfinput field I want to use is doesn't exist, because the form hasn't posted yet.

Is there away to use ColdFusion.GetElementValue() and put the results in a CF variable I can use in this query?

Nathan Manning

This topic has been closed for replies.

1 reply

Inspiring
January 24, 2013

Why don't you simply post the form?