0

州、地区、学校の 3 つの選択ボックスがあります。最初の 2 つは、学校がなくてもうまく機能しますが、実際には学校が重要な部分です。学校を選択しないと、すべてが正常に機能します。スクールボックスを使用すると、次のエラーが表示されます。

バインドに失敗しました。要素が見つかりません: pid

フロン

<cfcomponent>
    <cfset THIS.dsn="whatever">

    <cffunction name="getDistricts" access="remote" returntype="query">
        <cfargument name="state" required="yes" hint="The districts are in this state." />
        <cfstoredproc datasource="#THIS.dsn#" procedure="getSchoolAndDistrict" returncode="yes">
            <cfprocparam cfsqltype="cf_sql_varchar" dbvarname="@mstate" value="#arguments.state#" type="in">
            <cfprocresult resultset="1" name="districts">
        </cfstoredproc>
        <cfreturn districts>
    </cffunction>


    <cffunction name="getSchools" access="remote" returntype="query">
        <cfargument name="state" required="yes" hint="The districts are in this state." />
        <cfargument name="pid" required="yes" hint="The district pid." />
        <cfstoredproc datasource="#THIS.dsn#" procedure="getSchoolAndDistrict" returncode="yes">
            <cfprocparam cfsqltype="cf_sql_varchar" dbvarname="@mstate" value="#arguments.state#" type="in">
            <cfprocparam cfsqltype="cf_sql_varchar" dbvarname="@pid" value="#arguments.pid#" type="in">
            <cfprocresult resultset="2" name="schools">
        </cfstoredproc>
        <cfreturn schools>
    </cffunction>

</cfcomponent>

CFM

<cfoutput>
<cfform action="#CGI.PATH_INFO#" name="testdistricts" method="post">

    <cfselect name="states" query="states" 
         queryPosition="below"  
         display="state" value="state">
        <option value="">State</option>
    </cfselect>
    &nbsp;
    <cfselect name="districts" 
         bind="cfc:cfcs.getDistricts.getDistricts({states})" 
         queryPosition="below" 
         display="name" value="pid" bindonload="no">
        <option value="">District</option></cfselect>
    &nbsp;
    <cfselect name="schools" 
          bind="cfc:cfcs.getDistricts.getSchools({pid})" 
          queryPosition="below" 
          display="name" value="pid" bindonload="no">

        <option value="">School</option>
    </cfselect>
    <br> <br>

    <cfinput type="submit" name="submit" value="Submit">
</cfform>
</cfoutput>
4

1 に答える 1

0

あなたの問題は、学校の選択が、地区コントロール自体にバインドされるのではなく、選択されたオプションの値にバインドされることです...

    <cfform action="#CGI.PATH_INFO#" name="testdistricts" method="post">

    <cfselect name="states" query="states" 
         queryPosition="below"  
         display="state" value="state">
        <option value="">State</option>
    </cfselect>
    &nbsp;
    <cfselect name="districts" 
         bind="cfc:cfcs.getDistricts.getDistricts({states})" 
         queryPosition="below" 
         display="name" value="pid" bindonload="no">
        <option value="">District</option></cfselect>
    &nbsp;
    <cfselect name="schools" 
          bind="cfc:cfcs.getDistricts.getSchools({districts})" 
          queryPosition="below" 
          display="name" value="pid" bindonload="no">

        <option value="">School</option>
    </cfselect>
    <br> <br>

    <cfinput type="submit" name="submit" value="Submit">
</cfform>

これはあなたの問題があるところです

bind="cfc:cfcs.getDistricts.getSchools({districts})" 
于 2014-09-05T09:35:49.687 に答える