Robert, Try:
<cfoutput> <cfset i = i + 1> <cfset "StateArray#State#[i]" = HSName> </cfoutput> Notice, that you didn't have the <cfset> tag in your original code, and I didn't see that you were inside of a set of <cfscript> tags. Also note, that because you're inside of a <cfset> tag, you do not need the pound signs around HSName. You *DO* need them if you're using a dynamic variable on the left of the assignment operator. I hope this helps. Cheers, Chris Robert L Nunez II wrote: > Hello fellow Newbs and Experts, > > I have been trying to program CF Related Selects for the past couple of > days now and i have it a major road block. After corresponding to > various mailing groups and forums; I came across a site that would > appear to contain the code that I needed for my web form. Unfortunately > due to the way the form is set up, it is extremely difficult to do what > I am attempting so I created an alternate Index file to test out my > code. After much tweaking, I now error out on one line of code > "StateArray#State#[#i#] = #HSName#;" And I have no idea what is wrong. I > try to change it to "StateArray#State#[#i#] = #HSState#;" but then it > only returns the states and no High School Names. I would appreciate any > help that can be offered. > Thank you > > The rest of my code is as follows: > > <!--- Select the states and area codes. ---> > <cfquery datasource="DS" name="GetStates"> > SELECT S.State, HS.HSState > FROM States S, HighSchoolInfo HS > WHERE S.State=HS.HSState > ORDER BY S.State desc, HS.HSState > </cfquery> > > <!--- Select all the area codes. ---> > <cfquery datasource="DS" name="GetHighSchools"> > SELECT HighSchoolInfo.HSCode, HighSchoolInfo.HSName, > HighSchoolInfo.HSCity, HighSchoolInfo.HSState > FROM HighSchoolInfo > ORDER BY HSName > </cfquery> > > <script language = "JavaScript"> > <!-- > // For each state, create an array to hold the area codes. > // Each state array will be identified by the two-character state > abbreviation > <cfoutput query="GetStates" group="State"> > // Create the array > StateArray#State# = new Array(); > <cfset i = 0> > // Populate the array > <cfoutput> > <cfset i = i + 1> > StateArray#State#[#i#] = #HSName#; > </cfoutput> > </cfoutput> > > // Function to populate the area codes for the state selected > function PopulateHSName() { > // Only process the function if the first item is not selected. > if (document.OpenHouse.State.selectedIndex != 0) { > // Find the state abbreviation > var ThisState = > document.OpenHouse.State[document.OpenHouse.State.selectedIndex].value; > // Set the length of the arecode drop down equal to the length of > the state's array > document.OpenHouse.HSName.length = eval("StateArray" + ThisState + > ".length"); > // Put 'Select' as the first option in the area code drop-down > document.OpenHouse.HSName[0].value = ""; > document.OpenHouse.HSName[0].text = "Select"; > document.OpenHouse.HSName[0].selected = true; > // Loop through the state's array and populate the area code drop > down. > for (i=1; i<eval("StateArray" + ThisState + ".length"); i++) { > document.OpenHouse.HSName[i].value = eval("StateArray" + > ThisState + "[i]"); > document.OpenHouse.HSName[i].text = eval("StateArray" + > ThisState + "[i]"); > } > } > } > //--> > </script> > > > <form name="OpenHouse"> > <p> > <table border="0"> > <tr> > <td><b>State</b></td> > <td><b>High School</b></td> > </tr> > <tr> > <td> > <select name="State" onChange="PopulateHSName()"> > <option value="0">Select State > <cfoutput query="GetStates" group="State"> > <option value="#State#">#State# > </cfoutput> > </select> > </td> > <td> > <select name="HSName"> > <option value=""> > <cfoutput query="GetHighSchools"> > <option value="#HSCode#">#UCase(HSName)# -- #UCase(HSCity)#, > #UCase(HSState)# > </cfoutput> > </select> > </td> > </tr> > </table> > </p> > </form> > > -- http://www.cjordan.us ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 by AdobeĀ® Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:279644 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4