?
Solved

ColdFusion 8 - How to display data selected from a select list populated w/query

Posted on 2011-05-03
11
Medium Priority
?
592 Views
Last Modified: 2012-06-21
I need help with two items please.

I'm attempting to create a multi-part form using ColdFusion 8 TabLayout. In the first page/tab/form, I am populating a select drop-down list with a query to the database to get a list of code numbers. After the user selects one of the codes in the list, I need the Description to display on this same page/tab#1 (Description is also in the same query).

Then, if that Description is correct, the user is to click a Continue button and that creates the second tab. There's a lot more to this application that I'm trying to do, but will address that in another question. For now, I just need help with making these two features work. (1) the display of data (Description) after selecting a code from the select drop-down list, and (2) How to create the second & third tabs, which isn't currently working correctly. There are three pages of code, each very short. so I'm attaching.

I think I need an IF statement for the display of data "Description," but I haven't been able to figure that out yet. Your help is greatly appreciated.

Please let me know if this makes sense, or if you have any questions.

Thank you so much!

elizabeth ;-)


 
PAGE/TAB 1

<cfquery  name="Q_CPT_CODES" datasource="xxxxx">
SELECT
CODE_ID,
CPT_DRG_CODE,
CPT_DESCRIPTION
FROM cpt_drg_code
</cfquery>
<html>
<head>
</head>
<body>
<cfform name="layouts">
<cflayout type="tab" name="tabLayout">
    <cflayoutarea name="tab1" title="1. Introduction" align="left">
        Instructions will go here<br>
<select name="CODE_ID" height="200">
<cfoutput query="Q_CPT_CODES">
<option value="#CODE_ID#" <CFIF Q_CPT_CODES.CurrentRow EQ 1>SELECTED</CFIF>>#CPT_DRG_CODE#</option>
</cfoutput>
</select><br>
<cfinput type="button" name="CreateTab" 
        onClick="ColdFusion.Layout.createTab('tabLayout','tab2',
            '2. Patient Information','working_form1.cfm',{inithide:false,selected:true})" 
        value="Continue_Create_Tab">
    </cflayoutarea>
</cflayout></cfform>
</body>
</html>

Open in new window

PAGE/TAB 2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form 2</title>
</head>

<body>
<h3>Patient Information</h3>
Form will go here and CPT code value from first tab/page will be retained in the session scope.
<cfform name="layouts">
<cflayout type="tab" name="tabLayout">
    
        Form will go here<br>
<br>
<cfinput type="button" name="CreateTab" 
        onClick="ColdFusion.Layout.createTab('tabLayout','tab3',
            '3. Insurance Information','working_form2.cfm',{inithide:false,selected:true})" 
        value="Continue_Create_Tab2">
</cflayout></cfform>
</body>
</html>

Open in new window

PAGE/TAB 3

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form 1</title>
</head>

<body>
<h3>Insurance Information</h3>
Form will go here.
<cfform name="layouts">
<cflayout type="tab" name="tabLayout">
    
        Instructions will go here<br>
<br>
<cfinput type="button" name="CreateTab" 
        onClick="ColdFusion.Layout.createTab('tabLayout','tab3',
            '3. Insurance Information','working_form1.cfm',{inithide:false,selected:true})" 
        value="Submit">
    </cflayoutarea>
</cflayout></cfform>
</body>
</html>

Open in new window

0
Comment
Question by:Elizabeth2
  • 7
  • 3
11 Comments
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 35513938
You could use cfdiv in the cftab

Bind the cfdiv  to  url/cfm,  pass id as url argument to get the description/more details.


0
 

Author Comment

by:Elizabeth2
ID: 35514216
Thank you, but I'm afraid that's over my head.

I have found this page: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_r-s_14.html, but I don't know how to do this or why I'm doing this. Can you be a little more informative? I'm using CF8.

Thank you.
0
 

Author Comment

by:Elizabeth2
ID: 35515056
If anyone else has time to help, I would appreciate it very much. I have a deadline that is facing me.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 29

Expert Comment

by:Pravin Asar
ID: 35516151
Here is example code for you

<!-- cfselectdemo.cfm -->

<cfscript>
qryData=querynew ("id,optionvalue,optiondisplay,details","Integer,Varchar,Varchar,VarChar");
for (ix=0; ix < 10; ix++) {
      t=queryaddrow(qryData);
      t=querySetCell(qryData,"id",ix);
      t=querySetCell(qryData,"optionvalue", "value" & ix);
      t=querySetCell(qryData,"optiondisplay", "Option " & ix);
      t=querySetCell(qryData,"details", "Details for Option " & ix);
}
</cfscript>

<cfform name="f1">
<cfselect name="sel1" query="qryData" value="optionvalue" display="optiondisplay"/>
</cfform>
<cfdiv bindonload="false" id="details"  bind="url:getMoreDetails.cfm?id={sel1}"></cfdiv>


<!-- getMoreDetails.cfm -->


<cfif #isdefined('url.id')#>
<h1>HERE THE MORE DETAILS FOR <cfoutput>#url.id#</cfoutput></h1>
<cfset variables.id=#url.id#/>
<cfelse>
<cfset variables.id="value2"/>
</cfif>
<cfscript>
qryData=querynew ("id,optionvalue,optiondisplay,details","Integer,Varchar,Varchar,VarChar");
for (ix=0; ix < 10; ix++) {
      t=queryaddrow(qryData);
      t=querySetCell(qryData,"id",ix);
      t=querySetCell(qryData,"optionvalue", "value" & ix);
      t=querySetCell(qryData,"optiondisplay", "Option " & ix);
      t=querySetCell(qryData,"details", "Details for Option " & ix);
}
</cfscript>


<cfquery  dbtype="query"  name="detqry">
select id,optionvalue, details,optiondisplay
from qryData
where optionvalue='#variables.id#'
</cfquery>
<cfdump var="#detqry#"/>
0
 

Author Comment

by:Elizabeth2
ID: 35516760
I'm trying to digest this code. Thank you very much. The "details" are what is throwing me. I don't understand that line. I only have three fields in the table, CODE_ID,CPT_DRG_CODE,CPT_DESCRIPTION. I removed everything pertaining to "details" and did a find and replace on the other options, and I have it sort of working, but I need the select box to be populated with the CPT_DRG_CODE, and then the display to be the CPT_DESCRIPTION. Everything I've tried isn't working.

I guess I need more specific help. How do I get the select box to populate with the values from CPT_DRG_CODE? If I add the hash signs to anything named "value" I get an error.

Help, please.

elizabeth
0
 

Accepted Solution

by:
Elizabeth2 earned 0 total points
ID: 35690207
Unfortunately, I was not able to use your suggest concerning "binding," as that was a concept that I'm not yet familiar with. I was able to accomplish populating the select list, a check-box to make the Description display, using the code attached below to my page which can be seen here:
http://www.sjcarepricer.org/working4/index.cfm

I have not yet solved the tab issue, but I may just need to make separate pages giving the appearance of tabs, since only one tab is active at a time anyway. Thank you for the attempted help. Sorry I didn't understand what you were trying to convey.
<cfquery  name="Q_CPT_CODES" datasource="xxxxx">
SELECT
CODE_ID,
CPT_DRG_CODE,
CPT_DESCRIPTION
FROM cpt_drg_code
</cfquery>


 <select name="CPT_DRG_CODE">
        <cfoutput query="Q_CPT_CODES">
          <option value="#CPT_DRG_CODE#" <CFIF Q_CPT_CODES.CurrentRow EQ 1>SELECTED</CFIF>>#CPT_DRG_CODE#</option>
        </cfoutput></select>

<input name="correct_code" type="checkbox" value="correct_description" onclick="if(this.checked) this.form.submit();" />


 <cfoutput>
<cfif isDefined('form.CPT_DRG_CODE')>
    <cfset page.CPT_DRG_CODE = form.CPT_DRG_CODE>


  <!--- query DB for the Description --->
  <cfquery  name="myForm2" datasource="xxxxx">
SELECT
CODE_ID,
CPT_DRG_CODE,
CPT_DESCRIPTION
FROM cpt_drg_code
WHERE  CPT_DRG_CODE = '#form.CPT_DRG_CODE#'
</cfquery>

<cfoutput>#myForm2.CPT_DESCRIPTION#</cfoutput>
</cfif>
</cfoutput>

Open in new window

0
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 35693756
Get confidence,

Copy & Paste the posted code [earlier post]

save to files

1. cfselectdemo.cfm

2. getMoreDetails.cfm

Coldfusion Binding works with CFSELECT field [not with <select>]

0
 

Author Comment

by:Elizabeth2
ID: 35693784
You are right. I don't have any confidence.

Great! Thank you. I'll give it a try. That must have been my problem. I can't see the forest for the trees.

Thank you. I will get back to you tonight.

elizabeth ;-)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35694766
An even simpler example (tested in CF9)

... run your queries ... 
<cfform name="f1">
	<select id="CPT_DRG_CODE" name="CPT_DRG_CODE">
		<cfoutput query="Q_CPT_CODES">
	    	<option value="#CPT_DRG_CODE#" descrip="#CPT_DESCRIPTION#">#CPT_DRG_CODE#</option>
		</cfoutput>
	</select>
	<cfdiv name="description" bind="{CPT_DRG_CODE.descrip@change}"/>
</cfform>

Open in new window

0
 

Author Comment

by:Elizabeth2
ID: 35703619
Sorry, I'm a day/night late, but I'm back at it again tonight. I'm trying this now. Thank you. Will update when finished.
0
 

Author Closing Comment

by:Elizabeth2
ID: 35718379
I was not able to use the suggestion provided, so I continued to research and study on my own, and found a solution that is working. The other part of my quest, the tabs, has not yet been solved, so I will submit a question specifically for that purpose and task.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question