Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Null in a cfselect

Status
Not open for further replies.

yippiekyyay

Programmer
Oct 26, 2002
186
CA
Hello,

I have a dropdown list that lets the user select a subtype from a couple of different options (list is generated from a query). The problem is that sometimes there is no subtype, but I can't seem to get a "null" in there so it always defaults to the first option.

Any help would be greatly appreciated!

<cfselect name = "mySubtype" query = "getSubtypes" selected = "#subtype_ID#" value = "subtype_ID" display = "subtype_name"></cfselect>
 
Can you change your query to not return NULLs?

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Thanks for answering so quickly ECAR!

Currently, my query does not return any nulls - that's kinda the problem.

Say the subtypes are: red, blue and green
When the form opens to a specific record, "red" appears in the select box because no subtype had been assigned to this record.

Thanks again!

(So far, the only thing I can think of is to add an "N/A" as a subtype field)
 
In that case I always load an empty select option
Code:
<option> </option>
before I start looping through the query and loading the rest of the options. That way a blank line is the default option.

Lyndon
 
ooops!

Forgot to add that I don't use cfselect beacuse of limitations like that. Selects are just so easy build that there's never been any value added by using cfselect.

If you really must use cfselect then add a row to your query using
Code:
 QueryAddRow(query [, number ])
and store a space in it using
Code:
 QuerySetCell(query, column_name, value [, row_number ])
 
Hey Lyndon,

I ended up dropping the cfselect as you suggested and hard coding the options seeing as each of the dropdowns only had 3 options.

I've never heard of "QueryAddRow" and "QuerySetCell" before - I plan on trying to implement this afterwards (just in case my next project needs several options).

Thanks again for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top