• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Select Query and Recordset on same page

Explorer ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

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. 

Views

256

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation