Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
555 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 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