HI Donna,

These two Ben Forta tutorials may help: 
http://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects

http://www.adobe.com/devnet/coldfusion/articles/cf_pwrd_ajax_pt1.html

In a nutshell you create a cfc with your queries in two different functions, 
one for your first select and the second for the related select. Then on your 
display page you use cfform and cfselect you build your related selects.

Using Ben Forta's example

<cfform etc>
<!--- your first select --->
<cfselect name="mediaid"
             bind="cfc:art.getMedia()"
             value="mediaid"  
             display="mediatype"
             bindonload="true" />

</cfform>
<!--- the bind attribute lists the cfc - art.cfc and function - getMedia()that 
are associated with the select. Value is the id of the option and mediaType is 
what is displayed. The bindOnLoad attribute tells CF to load up the results of 
the query on page load --->

<!--- Your second/related select is a bit different --->
<cfselect name="artid"
             value="artid"
             display="artname"
             bind="cfc:art.getArt({mediaid})" />
<!--- This is the related select. The bind statement lists the CFC and the 
functions associated with this select. Notice that the getArt function requires 
an attribute - mediaId. That comes from the first select. --->

Anyhow go through the two tutorials. BTW this method works for any number of 
related selects.

there are a lot of blog posts and tutorials on the subject. Other good places 
to look for examples are easyCFM.com, Ben Nadels blog and Ray Camden's blog etc.

hth,
larry

> Good evening, all,
> 
> This may not be directly linked with ColdFusion, but am really needing 
> advice on this one...
> 
> I will be populating a dropdown list with CF from an SQL database.  I 
> need for a second dropdown to be populated based on the selection in 
> the first dropdown--without refreshing the page.  Is the best way to 
> do this with Javascript?  If so, do any of you have some sample code?   
> I'm not as familiar with Javascript as I should be.
> 
> Also, do you think it would be possible to use the same code to have a 
> third dropdown populated by the selection on the second?
> 
> One more question: I'm thinking of purchasing a book to help fill in 
> the gigantic 'black hole' in my knowledge base regarding Javascript...
> Any suggestions as to title/author?
> 
> I appreciate any advice you might have on this...
> 
> Many thanks,
> Donna
> 
> PS - I enjoy this list although I'm mostly a silent observer.  This 
> time, I'm really needing help, and will be most grateful for any 
> assistance you can offer.
> 
> ________________________________
> This e-mail message (including any attachments) is for the sole use 
> of
> the intended recipient(s) and may contain confidential and privileged
> information. If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination, 
> distribution
> or copying of this message (including any attachments) is strictly
> prohibited.
> 
> If you have received this message in error, please contact
> the sender by reply e-mail message and destroy all copies of the
> original message (including attachments).


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5055
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to