Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting a default value in Cfselect

LEGEND ,
Jun 01, 2006 Jun 01, 2006
I have the following code. I want the selected value to correspond to the value but apparently that only works with a
cfselect that gets its values from a query. Is there a way to set the default price in a plain select?

<cfselect name="price" size="1" value="#myclassifiedquery.price#">
<option>10</option>
<option>25</option>
<option>50</option>
<option>100</option>
<option>250</option>
<option>500</option>
<option>1000</option>
<option>2500</option>
<option>5000</option>
<option>10000</option>
<option>25000</option>
<option>50000</option>
</cfselect>
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 01, 2006 Jun 01, 2006
<option
<cfif myclassifiedquery.price is 500> selected="selected"
</cfif>
value = "500"
> <!--- closing option tag --->
500
</option>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 01, 2006 Jun 01, 2006
Thanks Dan. I decided creating a table with the values was a little more maintable.

But I have a different problem. The selected value is not displaying. When I look at the source code it says its
selected, but the first value on the list is still displayed. Is that standard procedure?

On Thu, 1 Jun 2006 22:18:37 +0000 (UTC), "Dan Bracuk" <webforumsuser@macromedia.com> wrote:


><option
><cfif myclassifiedquery.price is 500> selected="selected"
></cfif>
>> <!--- closing option tag --->
>500
></option>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 01, 2006 Jun 01, 2006
No it's not standard. However, this is:
<cfselect query="somequery" value="id" display="another_field" selected="something_else">

If the value something_else does not match one of the id fields somequery, the 'selected="something_else"' will be ignored and the first item will be displayed. It has to be an exact match too, ie 1 does not equal 1.0 and that sort of thing.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2006 Jun 03, 2006
LATEST
Thanks for the help. That was it, I failed to put ## around the variable.

On Fri, 2 Jun 2006 02:57:27 +0000 (UTC), "Dan Bracuk" <webforumsuser@macromedia.com> wrote:


>No it's not standard. However, this is:
> <cfselect query="somequery" value="id" display="another_field"
>selected="something_else">
>
> If the value something_else does not match one of the id fields somequery, the
>'selected="something_else"' will be ignored and the first item will be
>displayed. It has to be an exact match too, ie 1 does not equal 1.0 and that
>sort of thing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources