ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 10th, 2005, 04:23 AM
Merlincraft Merlincraft is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 65 Merlincraft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 53 sec
Reputation Power: 4
Question Dynamic Form Fields with ENUM

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..?

Reply With Quote
  #2  
Old October 10th, 2005, 11:15 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,661 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 14 h 23 m 22 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old October 10th, 2005, 01:47 PM
Merlincraft Merlincraft is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 65 Merlincraft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 53 sec
Reputation Power: 4
I am not sure..

Quote:
Originally Posted by kiteless
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?


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.

Reply With Quote
  #4  
Old October 10th, 2005, 06:03 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,661 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 14 h 23 m 22 sec
Reputation Power: 53
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).

Reply With Quote
  #5  
Old October 14th, 2005, 09:30 AM
Merlincraft Merlincraft is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 65 Merlincraft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 53 sec
Reputation Power: 4
Enum

Quote:
Originally Posted by kiteless
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).


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

Reply With Quote
  #6  
Old October 14th, 2005, 10:10 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,661 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 14 h 23 m 22 sec
Reputation Power: 53
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Dynamic Form Fields with ENUM


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway