Solved

How to pass CFFORM variable into another query after I selecting a values from first drop down list in the same FORM?

Posted on 2002-03-24
5
543 Views
Last Modified: 2013-12-24
For more details, pls have a look into the below code:

I have 3 drop down button and the corresponding query is given below :

Once I select Cob(1) and cUprFSACode (2) from the drop down button, The value of thired (cDBFN) values
is always which are available under cUprFSACode.

Pls see the line comments for where the problem is.




<!--- QUERY 1 --->

<CFQUERY NAME="SelCob" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
     SELECT distinct convert(char,dBusinessDate,111) 'Cob'
     FROM     tblPastDate
     order by dBusinessDate desc
</CFQUERY>

<!--- QUERY 2 --->

<CFQUERY NAME="SelAcct" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
SELECT      distinct cUprFSACode
FROM     tblFSAAcctNameJa
ORDER BY cUprFSACode
</CFQUERY>

<!--- QUERY 3 --->

<CFQUERY NAME="SelDBFN" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
SELECT      distinct cDBFN
FROM     tblDBFN
where cDBFN != ' '
and cAcct_Aum = "#----------#"      ==> I need to specify the 'cUprFSACode' variable here.
                         PS : This variable should come after user select the
                                          second drop down botton.
order by cDBFN asc
</CFQUERY>


<HTML>
<HEAD>
     <TITLE>ABCD - Menu</TITLE>
     <SCRIPT LANGUAGE="JavaScript">

</SCRIPT>
</HEAD>

<CFFORM NAME="form" ACTION="ABCDList.cfm" TARGET="main">
<TABLE BORDER="0">
          <TR>
               <TD>&nbsp;
          </TR>
          <TR>
               <TD COLSPAN="1" ><font color="white"><B>ABCD</B></font></TD>
               <TD COLSPAN="1" ><font color="white"><B>FSACode</B></font></TD>
               <TD COLSPAN="1" ><font color="white"><B>DBFN</B></font></TD>
          </TR>
          <TR>
               <TD>
               <CFSELECT NAME="CobList"
                        QUERY="SelCob"
                        VALUE="Cob"
                        DISPLAY="Cob"
                        REQUIRED="yes"
                        SIZE="1">
               </CFSELECT>
               </TD>
               <TD>
               <CFSELECT NAME="AcctList"
                        QUERY="SelAcct"
                        VALUE="cUprFSACode"
                        DISPLAY="cUprFSACode"
                        REQUIRED="yes"
                        SIZE="1">
               </CFSELECT>
               </TD>
               <TD>
               <CFSELECT NAME="DBFNList"
                        QUERY="SelDBFN"
                        VALUE="cDBFN"
                        DISPLAY="cDBFN"
                        REQUIRED="yes"
                        SIZE="1">
               </CFSELECT>
               </TD>
               <TD>
                    <INPUT TYPE="submit" NAME="Go" Value="Go" ><font color="red"></font>
                    <INPUT TYPE="radio" NAME="ViewType" Value="Browser" CHECKED><font color="white">In Browser</font>
                    <INPUT TYPE="radio" NAME="ViewType" Value="Excel"><font color="white">Excel Download</font>
               </TD>
          </TR>
</TABLE>
</CFFORM>

</BODY>

</HTML>
0
Comment
Question by:cmurugavel
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Cyril_H
ID: 6893438
You have to reload the entire form (easiest way) or Create Javascript Arrays (if your query doesn't contains lot of values). Here's the code for the 1st solution :

<!--- QUERY 1 --->

<CFQUERY NAME="SelCob" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
    SELECT distinct convert(char,dBusinessDate,111) 'Cob'
    FROM     tblPastDate
    order by dBusinessDate desc
</CFQUERY>

<!--- QUERY 2 --->

<CFQUERY NAME="SelAcct" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
SELECT      distinct cUprFSACode
FROM     tblFSAAcctNameJa
ORDER BY cUprFSACode
</CFQUERY>

<CFIF (IsDefined("Form.AcctList")) AND (Form.AcctList IS NOT "")>
<!--- QUERY 3 --->

<CFQUERY NAME="SelDBFN" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
SELECT      distinct cDBFN
FROM     tblDBFN
where cDBFN != ' '
and cAcct_Aum = "#Form.AcctList#"    
order by cDBFN asc
</CFQUERY>

</CFIF>

<HTML>
<HEAD>
    <TITLE>ABCD - Menu</TITLE>
    <SCRIPT LANGUAGE="JavaScript">

</SCRIPT>
</HEAD>

<CFPARAM NAME="Form.CobList" DEFAULT="">
<CFPARAM NAME="Form.AcctList" DEFAULT="">
<CFPARAM NAME="Form.DBFNList" DEFAULT="">
<CFPARAM NAME="Form.ViewType" DEFAULT="">

<CFFORM NAME="form" ACTION="ABCDList.cfm" TARGET="main">
<TABLE BORDER="0">
         <TR>
              <TD>&nbsp;
         </TR>
         <TR>
              <TD COLSPAN="1" ><font color="white"><B>ABCD</B></font></TD>
              <TD COLSPAN="1" ><font color="white"><B>FSACode</B></font></TD>
              <TD COLSPAN="1" ><font color="white"><B>DBFN</B></font></TD>
         </TR>
         <TR>
              <TD>
              <CFSELECT NAME="CobList"
                       QUERY="SelCob"
                       VALUE="Cob"
                       DISPLAY="Cob"
                       REQUIRED="yes"
                       SIZE="1"
                       SELECTED="Form.CobList">
              </CFSELECT>
              </TD>
              <TD>
              <CFSELECT NAME="AcctList"
                       QUERY="SelAcct"
                       VALUE="cUprFSACode"
                       DISPLAY="cUprFSACode"
                       REQUIRED="yes"
                       SIZE="1"
                       SELECTED="Form.AcctList">
              </CFSELECT>
              </TD>
              <TD>
              <CFIF (IsDefined("Form.AcctList")) AND (Form.AcctList IS NOT "")>
              <CFSELECT NAME="DBFNList"
                       QUERY="SelDBFN"
                       VALUE="cDBFN"
                       DISPLAY="cDBFN"
                       REQUIRED="yes"
                       SIZE="1"
                       SELECTED="Form.DBFNList">
              </CFSELECT>
              </CFIF>
              </TD>
              <TD>
                   <INPUT TYPE="submit" NAME="Go" Value="Go" ><font color="red"></font>
                   <INPUT TYPE="radio" NAME="ViewType" Value="Browser" <CFIF (Not IsDefined("Form.ViewType")) OR (Form.ViewType IS "Browser")>CHECKED</CFIF>><font color="white">In
Browser</font>
                   <INPUT TYPE="radio" NAME="ViewType" Value="Excel" <CFIF (IsDefined("Form.ViewType")) AND (Form.ViewType IS "Excel")>CHECKED</CFIF>><font color="white">Excel Download</font>
              </TD>
         </TR>
</TABLE>
</CFFORM>

</BODY>

</HTML>
0
 
LVL 2

Accepted Solution

by:
Cyril_H earned 50 total points
ID: 6893447
sorry i miss some code ;)

<!--- QUERY 1 --->

<CFQUERY NAME="SelCob" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
   SELECT distinct convert(char,dBusinessDate,111) 'Cob'
   FROM     tblPastDate
   order by dBusinessDate desc
</CFQUERY>

<!--- QUERY 2 --->

<CFQUERY NAME="SelAcct" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
SELECT      distinct cUprFSACode
FROM     tblFSAAcctNameJa
ORDER BY cUprFSACode
</CFQUERY>

<CFIF (IsDefined("Form.AcctList")) AND (Form.AcctList IS NOT "")>
<!--- QUERY 3 --->

<CFQUERY NAME="SelDBFN" DATASOURCE="#CSybDataSource#" USERNAME=#CSybUsername# PASSWORD=#CSybPassword#>
SELECT      distinct cDBFN
FROM     tblDBFN
where cDBFN != ' '
and cAcct_Aum = "#Form.AcctList#"    
order by cDBFN asc
</CFQUERY>

</CFIF>

<HTML>
<HEAD>
   <TITLE>ABCD - Menu</TITLE>
   <SCRIPT LANGUAGE="JavaScript">
   function ReloadForm() {
   form.action = "MyForm.cfm";
   form.submit();
   }
   </SCRIPT>
</HEAD>

<CFPARAM NAME="Form.CobList" DEFAULT="">
<CFPARAM NAME="Form.AcctList" DEFAULT="">
<CFPARAM NAME="Form.DBFNList" DEFAULT="">
<CFPARAM NAME="Form.ViewType" DEFAULT="">

<CFFORM NAME="form" ACTION="ABCDList.cfm" TARGET="main">
<TABLE BORDER="0">
        <TR>
             <TD>&nbsp;
        </TR>
        <TR>
             <TD COLSPAN="1" ><font color="white"><B>ABCD</B></font></TD>
             <TD COLSPAN="1" ><font color="white"><B>FSACode</B></font></TD>
             <TD COLSPAN="1" ><font color="white"><B>DBFN</B></font></TD>
        </TR>
        <TR>
             <TD>
             <CFSELECT NAME="CobList"
                      QUERY="SelCob"
                      VALUE="Cob"
                      DISPLAY="Cob"
                      REQUIRED="yes"
                      SIZE="1"
                      SELECTED="Form.CobList">
             </CFSELECT>
             </TD>
             <TD>
             <CFSELECT NAME="AcctList"
                      QUERY="SelAcct"
                      VALUE="cUprFSACode"
                      DISPLAY="cUprFSACode"
                      REQUIRED="yes"
                      SIZE="1"
                      SELECTED="Form.AcctList"
                           PASSTHROUGH="OnChange='ReloadForm();'">
             </CFSELECT>
             </TD>
             <TD>
             <CFIF (IsDefined("Form.AcctList")) AND (Form.AcctList IS NOT "")>
             <CFSELECT NAME="DBFNList"
                      QUERY="SelDBFN"
                      VALUE="cDBFN"
                      DISPLAY="cDBFN"
                      REQUIRED="yes"
                      SIZE="1"
                      SELECTED="Form.DBFNList">
             </CFSELECT>
             </CFIF>
             </TD>
             <TD>
                  <INPUT TYPE="submit" NAME="Go" Value="Go" ><font color="red"></font>
                  <INPUT TYPE="radio" NAME="ViewType" Value="Browser" <CFIF (Not IsDefined("Form.ViewType"))
OR (Form.ViewType IS "Browser")>CHECKED</CFIF>><font color="white">In
Browser</font>
                  <INPUT TYPE="radio" NAME="ViewType" Value="Excel" <CFIF (IsDefined("Form.ViewType"))
AND (Form.ViewType IS "Excel")>CHECKED</CFIF>><font color="white">Excel Download</font>
             </TD>
        </TR>
</TABLE>
</CFFORM>

</BODY>

</HTML>
0
 
LVL 1

Author Comment

by:cmurugavel
ID: 6917036
It didn't cover my entire requirement. But I have managed with your code and my additional code.

Thanks.
0
 
LVL 1

Author Comment

by:cmurugavel
ID: 6917037
It didn't cover my entire requirement. But I have managed with your code and my additional code.

Thanks.
0
 
LVL 1

Author Comment

by:cmurugavel
ID: 6917043
It didn't cover my entire requirement. But I have managed with your code and my additional code.

Thanks.
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now