1 Reply Latest reply on Apr 7, 2014 9:59 AM by BKBK

    Select Query and Recordset on same page

    NVL-Tom

      I have been workig with Coldfusion for a while now.  Where I work there is a need for web pages to extract data from data sources.  I have been successful at doing this.  Typically I use a form that selects multiple criteria, which when submitted loads a target/action page that displays records that are filtered based on the SQL statement contained on that action page.  What I do is to conditionally check if criteria is passed using cfif.  And if a field parameter is indeed passed it becomes part of the cfquery.  This works out well - especially for reporting.

       

      But now I am seeing more and more a need to accomplish the same process - but on a single cfm page.  So the page I seek will have both the form (select) and the recordset results on the same page. 

       

      In this exercise I will be caching results od a query and having several queries to further refine what I seek (QOQ).  What I am seeking is the best practice to follow, I was thinking that using an iframe on the page would be and adequate solution whereby the query would pass the criteria and its form action would pass the variable(s) to the action page, which would be the source of the iframe.  But I am not certain that this is a best proctice.  Nor have I had great success at getting the pages to work in concert. 

       

      Any advice that you can lend would be appreciated. 

        • 1. Re: Select Query and Recordset on same page
          BKBK Adobe Community Professional & MVP

          I ideally start by reducing the 2-page functionality - of form page and action page - to just one. It goes like this:

          <cfset isValidationPassed = false>

          <cfif isDefined("form.someVar")>

          <!--- Do validation. Validated form implies isValidationPassed is true --->

          </cfif>

           

          <cfif isValidationPassed>

          <!--- Do action page stuff --->

          <cfelseif NOT isDefined("form.someVar") OR NOT isValidationPassed>

          <!--- Display the form. --->

          <!--- If form had been submitted, inform user which validation failed, and what to correct. Display the form. --->

          <cfoutput><form method="post" action="#CGI.SCRIPT_NAME#"></cfoutput>

          </form>

          </cfif>

           

          The idea is then to pile on the complexity, layer by layer.