0
Setting a default value in Cfselect
LEGEND
,
/t5/coldfusion-discussions/setting-a-default-value-in-cfselect/td-p/768612
Jun 01, 2006
Jun 01, 2006
Copy link to clipboard
Copied
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>
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>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-default-value-in-cfselect/m-p/768613#M71497
Jun 01, 2006
Jun 01, 2006
Copy link to clipboard
Copied
<option
<cfif myclassifiedquery.price is 500> selected="selected"
</cfif>
value = "500"
> <!--- closing option tag --->
500
</option>
<cfif myclassifiedquery.price is 500> selected="selected"
</cfif>
value = "500"
> <!--- closing option tag --->
500
</option>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/coldfusion-discussions/setting-a-default-value-in-cfselect/m-p/768614#M71498
Jun 01, 2006
Jun 01, 2006
Copy link to clipboard
Copied
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>
>
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>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-default-value-in-cfselect/m-p/768615#M71499
Jun 01, 2006
Jun 01, 2006
Copy link to clipboard
Copied
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.
<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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/coldfusion-discussions/setting-a-default-value-in-cfselect/m-p/768616#M71500
Jun 03, 2006
Jun 03, 2006
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

