Hi Paul Here's some code I posted to a different list (burn the heretic etc.). The ey thing to remember is that ALL CF code executes before ANY JavaScript is processed, as the former happens on the server, the response is sent to the browser, and only then does the JavaScript kick in.
<cfquery datasource="dsn" name="getCats"> SELECT c.Category, c.CategoryID, s.subCategory, s.subCategoryID FROM subCategoryID s INNER JOIN Category c ON s.CategoryID = c.CategoryID ORDER BY c.CategoryID, s.subCategoryID </cfquery> <cfset prevCatID = ""> <script language="JavaScript"> <CFOUTPUT query="getCats"> <cfif getCats.CategoryID neq prevCatID> <!--- New category ---> subCatArray#getCats.CategoryID# = new Array(); <cfset i = 0> </cfif> subCatArray#getCats.CategoryID#[#i#] = '#getCats.subCategory#'; <cfset i = i + 1> <cfset prevCatID = getCats.CategoryID> </CFOUTPUT> function swapSubCats(subCategoryID) { var arrayToLoad = eval('subCatArray' + subCategoryID); loadArrayToSelectBox(arrayToLoad,document.myForm.subCategoryID); } function loadArrayToSelectBox(optionsArray,selectBox) { //Clear old options selectBox.options.length=0; for ( i = 0; i < optionsArray.length; i ++ ) { selectBox.options[i] = new Option(optionsArray[i],optionsArray[i],0,0); } } </script> <cfset prevCatID = ""> <form name="myForm"> <select name="CategoryID" onchange="swapSubCats(this.options[this.selectedIndex].value)"> <CFOUTPUT query="getCats"> <cfif getCats.CategoryID neq prevCatID> <!--- New category ---> <option value="#getCats.CategoryID#">#getCats.Category# </cfif> <cfset prevCatID = getCats.CategoryID> </CFOUTPUT> </select> <br><br> <select name="subCategoryID"> </select> </form> For Category, read menu / menugroup in your example, whilst for subcategory, read phase. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 26 May 2004 08:31 To: [EMAIL PROTECTED] Subject: [ cf-dev ] Relative Select List Having read an old Javascript book last night I now have .... WHERE (Menu_Group = Selected_menu.options[selected_menu.options.selectedIndex].value;) As expected this doesn't work either .... :( Can anyone help me with this one please? - My JavaScript is "even more worserer" than my Coldfusion (if it could be worse...) Regards - Paul **************************************************************************** ********************* The information contained within this e-mail (and any attachment) sent by Birmingham City Council is confidential and may be legally privileged. It is intended only for the named recipient or entity to whom it is addressed. If you are not the intended recipient please accept our apologies and notify the sender immediately, or telephone +(44) 121 303 6666. Unauthorised access, use, disclosure, storage or copying is not permitted and may be unlawful. Any e-mail including its content may be monitored and used by Birmingham City Council for reasons of security and for monitoring internal compliance with the office policy on staff use. E-mail blocking software may also be used. Any views or opinions presented are solely those of the originator and do not necessarily represent those of Birmingham City Council. We cannot guarantee that this message or any attachment is virus free or has not been intercepted and amended. **************************************************************************** ********************* -- These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/ Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ CFDeveloper Sponsors and contributors:- *Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by activepdf.com* *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com* *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com* To unsubscribe, e-mail: [EMAIL PROTECTED] -- These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/ Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ CFDeveloper Sponsors and contributors:- *Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by activepdf.com* *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com* *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com* To unsubscribe, e-mail: [EMAIL PROTECTED]