While 2 selectrelated does its job its a little heavy in the code side of things. Qforms is much better, epecially when you have a few sets on the same page..
http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm WG -----Original Message----- From: raedwards [mailto:[EMAIL PROTECTED] Sent: 13 August 2003 12:55 To: CF-Talk Subject: Re: OT: dynamically populating a select box from another select box Rather than trying to code everything yourself, you might want to look in the Exchange for a custom tag called CF_TwoSelectsRelated. This takes a query and outputs two select boxes so that when you pick one, it populates the other. I've tried it and it works great. I did have to tweak it some to allow me to add fields via cfscript before displaying the boxes, but otherwise it was good. Rob At 11:54 AM 8/13/2003 +0100, you wrote: >Hello > >Im trying to dynamically populate a select box from another select box... > >Here's the JS code: > ><script type="text/javascript" language="javascript"> >function createSelectBox (subsection, section) { // populate subsection box >according to section box > >// set up arrays ><cfloop query="sections"> ><cfsilent> > <cfquery name="subsection" ...> > SELECT * FROM subsectionInSection WHERE section = '#sections.name#' > </cfquery> > <cfset first = 1> ></cfsilent> >var #name# = new Array(<cfloop query="subsection"><cfif NOT >first>,</cfif>"#subsection.name#"<cfset first = 0></cfloop>); ></cfloop> > >// empty current items >for(i=subsection.options.length; i>=0; i--) > subsection.options[i] = null; > >// set array to use >useArray = section; > >// create new select >for(j=0; j<useArray.length; j++) > subsection.options[j] = new Option(useArray[j]); > >subsection.options[0].selected = true; > >} ></script> > >And it's called here: > ><select name="section" id="section" >onChange="createSelectBox(document.form.subsection, >this.options[this.selectedIndex].value);" > > >The JS gets passed the name of the section I want, which corresponds to the >name of the array I want... The problem is that instead of outputting the >array it is supposed to, it outputs the name of the section with each >character in a new option... > >How can I get it to output the array?! > >TIA, >Ryan > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

