|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
My apologies in advance if this seems long winded.. It really isn't I just can't explain it very well.
In situations where you have a 1 to many relationship that requires a form control to offer the user multiple options (e.g. a select control) it is easy to have the form control generated dynamically using SQL and even to focus on a particular value by joining the tables. As an example a movie in a database may have a rating from 1 - 5 from a ratings table. It is easy enough to include a dynamic control for updating this value using: <option value="#RatingID#" <cfif rating.RatingID IS film.RatingID> elected <cfif>>#Rating# However, is there a method for dynamically listing options for data of type enum. If rather than having a ratings table there is simple a rating enum of (Very Good, Good, Average, Poor), how do we dynamically generate the select control..? If there is no way to dynamically create the list box, is there at least an easy way to show focus on the current value for a form designed to update the record. E.g. For Radio Buttons: Very Good Good Average Poor Can we select the current value in the database..? |
|
#2
|
|||
|
|||
|
You can certainly create a dynamic list box. Just run a query that gets the ratings, or provide a list or array of the ratings, and loop over it. Is this what you are asking?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I am not sure..
Quote:
I know you can create a dynamic list box by looping over records in a query.. But if one of the attributes in a table is type enum.. is it possible to dynamically create a list box of the options in this attribute. E.g. attribute: enum filmRating(Good, Average, Bad). So the list box shows Good, Average, Bad... and if the form is for updating is it possible to focus on the current value of this attribute.. Or a smore simple example, an employee table with an enum attribute for checking if the employee is a member of a trade union.. e.g. enum union(yes, no, N/A) If the list box cannot dynamically find out the values available in the enum (which I am guessing they cannot) is it at least possible to focus on the current value of the attribute. So that, a checkbox control can show us the current value. |
|
#4
|
|||
|
|||
|
Until now I had never heard of Enum as a SQL data type. So unfortunately I don't know if/how you would access those types from CF. It doesn't appear valid in Oracle (which is the DB I most often use).
|
|
#5
|
|||
|
|||
|
Enum
Quote:
http://dev.mysql.com/doc/refman/5.0/en/enum.html Oracle does not have an ENUM type: http://thinkoracle.blogspot.com/200...-in-oracle.html |
|
#6
|
|||
|
|||
|
That's what I'm saying, because it is something that is specific to MySQL I'm not sure how a generic application server using JDBC could leverage it. From what I can tell it would have to be implemented within the JDBC driver itself for any Java system to leverage the ENUM type. This is a danger when one vendor impelements a feature that isn't part of the ANSI SQL standard.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Dynamic Form Fields with ENUM |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|