我有两个使用绑定的 cfselect 框和一个 cfc。一是状态。选择一个州,然后即时填充第二个 cfselect(县)。
在使用 bind 属性执行此操作之前,我依靠如下的 queryPostion="below" 属性基本上将一个空白行放入选项框中。我现在想对州和县选择框做同样的事情,因为我想在每个选项中都有“”值(或“ALL”值作为选项。但是 queryPostion 不再有效。我不是肯定有解决方法。
//original... leaves a blank option:
<cfselect enabled="No" name="search_state" multiple="no" query="get_States" value="StateUSAbb" display="StateName" queryPosition="below">
<option></option>
</cfselect>
//now, w/bind, doesn't work:
<cfselect bind="cfc:states.getStates()" bindonload="true" name="search_state"
value="StateUSAbb" display="StateName">
</cfselect>
<cfselect bind="cfc:states.getCounties({search_state})" bindonload="true" name="search_county" value="FIPS_County" display="CountyName" >
</cfselect>
两个查询的更新解决方案:
SELECT DISTINCT tblLoc.StateUSAbb, lkuState.StateName
FROM lkuState INNER JOIN tblLoc ON lkuState.FIPS_State = tblLoc.FIPS_State
WHERE (lkuState.StateName <> 'New Brunswick')
UNION
SELECT '' AS StateUSAbb, '' AS StateName
FROM lkuState
ORDER BY StateName
SELECT '' AS FIPS_COUNTY, '' as CountyName
FROM lkuCnty
UNION
SELECT FIPS_County, CountyName
FROM lkuCnty
WHERE StateAbb = '#ARGUMENTS.stateabb#'
ORDER BY CountyName