Skip to content
Advertisement

Problem with the value portion of a drop down menu in ColdFusion

Here is what I have inside of my select statement:

<cfloop query name="country">
    <option value="#CountryName#"><cfoutput>#CountryName#</cfoutput></option>
</cfloop>

Everything works fine, but the value it passes to my URL filter is #CountryName#, not the actual country name (i.e. Canada).

How can I assign it the value of the country name and not the variable name?

Advertisement

Answer

The #CountryName# variable is not being evaluated because it is outside your output tags. Move the tags so they encompass your value too.

<cfoutput><option value="#CountryName#">#CountryName#</option></cfoutput>

Or just use a <cfoutput query="..."> instead of <cfloop>.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement