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 January 17th, 2005, 08:17 AM
Moo Ouwan Moo Ouwan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 18 Moo Ouwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 37 m 53 sec
Reputation Power: 0
Dynamically prepopulating coldfusion multiple selection lists

Hello

I'm trying to prepopulate a multiple selection list with values.

The values of the list come from one table in a MySQL database and the values to be selected are fed from another table in the database.

Does anybody know how this is done? Basically I need to loop somehow through the table that provides the values to be selected.

The table that supplies the values that populate the list is called "regattas", whilst the table that supplies the values to be selected is called "getregattasboatsTB". It is regattasID in both tables that needs to equal one another.

The select code is like this:

<select name="Regattas" class="Body" size="5" multiple>
<option value" "></option>
<cfoutput query="Regattas">
<option value="#Regattas.RegattaID#"<#Regattas.RegattaName#></option>
</cfoutput>
</select>

Would appreciate any help on this one.

Cheers
Moo

Reply With Quote
  #2  
Old January 17th, 2005, 08:31 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 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 15 h 25 m 55 sec
Reputation Power: 53
What's the actual problem? The code you put up looks like it should populate the select box, except for the brackets being incorrect:

<select name="Regattas" class="Body" size="5" multiple>

<option value" "></option>
<cfoutput query="Regattas">
<option value="#Regattas.RegattaID#">#Regattas.RegattaName#</option>

</cfoutput>
</select>

So what is it about this code that isn't doing what you want?
__________________
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 January 17th, 2005, 10:58 AM
Moo Ouwan Moo Ouwan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 18 Moo Ouwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 37 m 53 sec
Reputation Power: 0
Yes, I'm afraid this is only so far as I've got!

You're right, this code dynamically populates the list, which I know how to do. I now want to take it a step further by selecting some of the values in this select list. But the values that I want to use come from a separate table in the dbase.

I will try to explain further:

I'm working on a yachting website. On it there is a search facility for finding boats that are available to take part in various regattas (for people wanting to gain experience of sailing regattas). Each boat is managed by the owner who decides which regattas he/she wants the boats to be available to take part in.

So I'm using a select list so that they can select a regatta (or more than 1 regatta) to indicate availability. The regattas are held in one table, boats in another and regattasboats in a third table. The page is obviously a data entry page but I want the select lists to be preselected with the regatta data they entered before for when the owner wishes to update his/her boat details.

All this happens on a page that is specific to one boat (the boat data entry/update page). The select list is prepopulated with the regattas that are held in the database of regatta names (values regattaID). I want those regattas that have already been specified for this boat to be already selected (from the table that combines boatIDs with regattaIDs).

PS I'm aware of the brackets in the wrong place

Thanks
Moo

Reply With Quote
  #4  
Old January 18th, 2005, 11:38 AM
fortunato fortunato is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 33 fortunato User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 52 sec
Reputation Power: 4
I see, it would be easier to explain the solution if you provided more details about your queries and errors, but I'll give it a shot.

Lets say your query for pre-selecting regattas is called "regattasForYacht" and it contains the fields yachtId, and regattaId.

I usually convert the regattaIds to a list, and then do a ListFind to preselect the matches from the generic regatta-list query. To do this, I use a CFIF statement embedded in the <option> tag. Like so...

<cfset preselectList = ValueList(regattasForYach.regattaId)>

<select name="Regattas" class="Body" size="5" multiple>
<option value" "></option>
<cfoutput query="Regattas">
<option value="#Regattas.RegattaID#"
<cfif ListFind(preselectList,regattas.regattaID>SELECTED</cfif>
>#Regattas.RegattaName#</option>
</cfoutput>
</select>

HTH, let me know

Reply With Quote
  #5  
Old January 20th, 2005, 06:30 AM
Moo Ouwan Moo Ouwan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 18 Moo Ouwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 37 m 53 sec
Reputation Power: 0
Brilliant, Fortunato. That's exactly what I was looking for. Many thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Dynamically prepopulating coldfusion multiple selection lists


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 3 hosted by Hostway
Stay green...Green IT