Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I have a blank first value in <cfselect>?

1 view
Skip to first unread message

webspinner

unread,
Feb 19, 2007, 11:28:23 AM2/19/07
to
I'm trying to have my drop down boxes show no initial values using cfselect.
Is this possible?

I only seem to be able to add

<option value = "">Select All

at the end, or I get an error.

Thanks!

Rick

Ian Skinner

unread,
Feb 19, 2007, 11:32:46 AM2/19/07
to
I only seem to be able to add

<option value = "">Select All

at the end, or I get an error.

Thanks!

Yeah, but I bet this would work anywhere in the select:

<option value = "">Select All</option>
OR
<option value = ""></option>
OR maybe
<option value = "" /> <!-- I've never tried this one, so I don't know if
it is legal -->

Sabaidee

unread,
Feb 19, 2007, 11:49:55 AM2/19/07
to
how are you using cfselect? with the query, display and value attributes or without them?
post you full cfselect code to check...

webspinner

unread,
Feb 19, 2007, 1:39:06 PM2/19/07
to
Thanks peeps.

Tried all these:

""Yeah, but I bet this would work anywhere in the select:

<option value = "">Select All</option>
OR
<option value = ""></option>
OR maybe
<option value = "" /> <!-- I've never tried this one, so I don't know if
it is legal -->""

No go. Got "Invalid token 'o' found on line 24 at column 12." errors for all
of them.

And the queryposition attribute is supported in CFMX7 and I'm working on CFMX
6.1.

Am I out of luck on 6.1? Seems like a pretty basic functionality.

Thanks again,

Rick

Chris Mueller

unread,
Feb 19, 2007, 1:49:54 PM2/19/07
to

Rick, the error you're describing sounds more like a ColdFusion bug
rather than an HTML bug. The <option value="">Select All</option> code
will work just fine. You'll need to check how you're handling this
case when you process the form with CF. If you post some code here I
might be able to help you find the problem (and hopefully a solution).

Azadi

unread,
Feb 19, 2007, 1:45:26 PM2/19/07
to

you MUST close all <option> tags inside <cfselect> with </option>,
otherwise they will not work properly (i.e. the first option will not be
displayed).

your "Invalid token 'o' found on line 24 at column 12." indicates that
your <option> tags are not closed.


webspinner

unread,
Feb 19, 2007, 2:07:21 PM2/19/07
to
But I did close them when I tried all three of these:

<option value = "">Select All</option>
OR
<option value = ""></option>
OR maybe
<option value = "" /> <!-- I've never tried this one, so I don't know if
it is legal -->""

and still got the invalid token:

Invalid token 'o' found on line 24 at column 12.

The CFML compiler was processing:

* a cfselect tag beginning on line 23, column 10.


The error occurred in sampleForm.cfm: line 24

22 : <cfform action="test.cfm" name="myForm">
23 : <cfselect
24 : <option value = ""></option>
25 : name = "course"
26 : message = "you must make a selection"


Chris Mueller

unread,
Feb 19, 2007, 2:19:18 PM2/19/07
to
This line is the culprit:
> 23 : <cfselect

You need to close the cfselect tag before starting the option tags.

Azadi

unread,
Feb 19, 2007, 2:07:14 PM2/19/07
to

GOODNESS! close the end bracket of your <cfselect>!!!
<option ...> go inbetween <cfselect> and </cfselect>, not INSIDE
<cfselect <option>>!!!!

c_wigginton

unread,
Feb 19, 2007, 2:10:54 PM2/19/07
to
You're not closing off your cfselect.

<cfselect>
<option value="">Select an value</option>
</cfselect>
Anyways, here's another solution if you pass in a query

Build it into the query using a union so that the first row has a null or ''
value and either a blank display or a message stating the user needs to make a
selection.

The below example uses oracle/dual. Tune for your database specifics.

<cfquery name="myQuery" datsource="myDSN">
select null as valueColumn, 'Select an Option" as displayColumn,0 as sortOrder
from dual
union
select valueColumn, displayColumn, 1 as sortOrder from myTable
order by sortOrder asc
</cfquery>
<cfselect display="displayColumn" value="valueColumn" query="myQuery" />


webspinner

unread,
Feb 19, 2007, 4:20:06 PM2/19/07
to
I thought it was clear I was pasting a dump of the error.

Here's the whole tag:

<cfform action="test.cfm" name="myForm">

<cfselect
name = "course"

message = "you must make a selection"

onError = "text"
size = "1"
multiple = "No"
selected = "none"
query = "links" value = "SiteName" required = "Yes">
</cfselect>
</cfform>

paross1

unread,
Feb 19, 2007, 5:29:32 PM2/19/07
to
What about this? I've done it this way without any problems.

<cfform action="test.cfm" name="myForm">
<cfselect
name = "course"

query = "links"
required = "Yes"


message = "you must make a selection"
onError = "text"
size = "1"
multiple = "No"
selected = "none"

value = "SiteName" >
<option value = "" selected>
</cfselect>
</cfform>

Phil


webspinner

unread,
Feb 20, 2007, 10:33:36 AM2/20/07
to
Bingo! Thanks, Phil. That works great.

Rick

0 new messages