很抱歉可能会问初学者问题并且对我的英语感到抱歉,但我似乎无法完成这项工作(我没有开发这个)。
我在 Coldfusion 中有 3 个选择下拉框。第一个下拉状态由数据库 onload 填充:
<cfquery name="qState" datasource="#Variables.fw.Config.DSN#">
SELECT * from refState WHERE State = '#url.BindID#' AND status = 'Active' order by ldesc
</cfquery>
<select name="State">
<option value="" <cfif isDefined("url.PrevID") and #url.PrevID# EQ "">selected</cfif>></option>
<cfoutput query="qState">
<option value="#qState.State#" <cfif isDefined("url.PrevID") and #url.PrevID# EQ #qState.State#>selected</cfif>>#qState.Ldesc#</option>
</cfoutput>
</select>
然后它将选定的值传递给第二个下拉列表,即 City:
<cfdiv id="City" bind="url:index.cfm?section=public&action=City&txtReff=#txtReff#&BindStateID={State}&PrevCityID=#txtCity#">
查询获取州下的城市:
<!--- loop to fix the state, returns the correct value even though i hav limited knowledge on this --->
<cfset num = 0>
<cfloop index="i" list="#url.BindStateID#" delimiters=",">
<cfset num = #num# + 1>
<cfif #num# EQ 2>
<cfset p = #i#>
</cfif>
</cfloop>
<!--- then the query to get cities under the state --->
<cfquery name="qCity" datasource="#Variables.fw.Config.DSN#">
SELECT * from refCity WHERE State = '#p#' AND status = 'Active' order by ldesc
</cfquery
>
最后显示要选择的城市
<select name="City">
<option value="" <cfif isDefined("url.PrevCityID") and #url.PrevCityID# EQ "">selected</cfif>></option>
<cfoutput query="qCity">
<option value="#qCity.City#" <cfif isDefined("url.PrevCityID") and #url.PrevCityID# EQ #qCity.City#>selected</cfif>>#qCity.Ldesc#</option>
</cfoutput>
</select>
问题是这仅适用于 IE6、7 和 8。它不适用于 Chrome、IE 9 及更高版本和 firefox。
任何帮助将非常感激。感谢你