ColdFusion - passing OnChange parameter to another form

Discussion in 'Programming' started by dtun, Sep 28, 2006.

  1. #1
    I am new to ColdFusion. I am trying to create a screen which has 3 frames.
    Frame 2 has a dropdown list and frame 3 is for the result based on the dropdown list selection.

    Onchange of the list in frame 2 I want to pass the selected item to frame 3 for the db query.

    I keep getting the error that the item I am passing Form.repid is not defined.

    How do I pass the selected value from frame 2 to frame 3?

    Thanks in advance!

    Here is the snippet of code I have so far:

    ReportDefFrames.cfm
    ===================
    <FRAMESET ROWS="10%,5%,*" BORDER="0" FRAMEBORDER="0" SCROLLING="NO" RESIZABLE="NO">
    <FRAME NAME="frameRepDefMenu" SRC="ReportDefMenu.cfm">
    <FRAME NAME="frameRepDefId" SRC="ReportDefId.cfm">
    <FRAME NAME="frameReportAttributes" SRC="ReportDefAttributes.cfm">
    </FRAMESET>

    ReportDefId.cfm
    ================
    <SCRIPT LANGUAGE="JAVASCRIPT">
    function getReportAttributes(element)
    {
    parent.frames['frameRepDefId'].document.frmreportid.txtReportId.value=element.options[element.selectedIndex].value;
    window.location.href = "ReportDefAttributes.cfm?repid="+element.options[element.selectedIndex].value
    }
    </SCRIPT>

    <BODY CLASS="std" TOPMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
    <form name="frmreportid" action="ActGetDefinition.cfm" method="post">
    <TABLE name="tbreportid" WIDTH="100%">
    <TR>
    <TD><FONT size="4"><B>Report Id</B></TD>
    <TD WIDTH="%85"><FONT size="4">
    <cfquery name="qGetReportId" datasource="eddstest">
    select rd_id from ais_reportdef order by rd_id
    </cfquery>
    <select name="ReportId" size="1"
    onchange=getReportAttributes(this)>
    <cfoutput query="qGetReportId">
    <option value="#qGetReportId.rd_id#">
    #qGetReportId.rd_id#
    </option>
    </cfoutput>
    </select>
    </TD>
    </TR>
    <TR>
    <input type="TEXT" name="txtReportId" value="">
    </TR>
    </TABLE>
    </form>
    </BODY>


    ReportDefAttributes.cfm
    =======================
    <BODY CLASS="std" TOPMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">

    <cfif isDefined("Form.repid") AND Form.repid IS NOT "">
    <cfoutput>
    <cfquery name="qGetDefinition" datasource="eddstest">
    SELECT rd_id, rd_company, rd_department, rd_account, rd_folder, rd_retention, rd_description
    FROM ais_reportdef
    WHERE rd_id ='#Form.repid#'
    </cfquery>
    </cfoutput>
    </cfif>

    <form name="frmReportDefAttributes">
    <TABLE name="tbInput" WIDTH="65%">
    <cfif isDefined("qGetDefinition")>
    <cfoutput query="qGetDefinition">
    <TR>
    <TD><FONT size="4"><B>Company</B></TD>
    <cfif isDefined("qGetDefinition")>
    <TD><INPUT TYPE="TEXT" NAME="txtCompany" SIZE="60" VALUE="#qGetDefinition.rd_company#" MAXLENGTH="50" TABINDEX="2" ACCESSKEY="C">
    </TD>
    <cfelse>
    <TD><INPUT TYPE="TEXT" NAME="txtCompany" SIZE="60" VALUE="" MAXLENGTH="50" TABINDEX="2" ACCESSKEY="C">
    </cfif>
    </TR>
    </cfif>
    </TABLE>
    </form>
     
    dtun, Sep 28, 2006 IP
  2. seamus.hogan

    seamus.hogan Peon

    Messages:
    31
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ajax would be a better way to do this. Have a trundle on google I'm sure you will find a solution
     
    seamus.hogan, Nov 2, 2006 IP