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
540 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
It didn't cover my entire requirement. But I have managed with your code and my additional code.

Thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

13 Experts available now in Live!

Get 1:1 Help Now