Try this. Replace this code:
// 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>
With this code:
// For each state, create an array to hold the area codes.
// Each state array will be identified by the two-character state
abbreviation
<cfset i = 0>
<cfoutput query="GetStates" group="State">
// Create the array
StateArray#State# = new Array();
<!--- Check to see if my state changed. --->
<cfif CheckState IS NOT State>
<cfset i = 0>
</cfif>
// Populate the array
StateArray#State#[#i#] = '#HSName#';
<cfset i = i + 1>
<cfset CheckState = State>
</cfoutput>
Chuck
-----Original Message-----
From: Robert L Nunez II [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 30, 2007 3:45 PM
To: CF-Newbie
Subject: CF Headache
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>
-- Robert L Nunez II IS Technical Services Assistant University of
Wisconsin-Milwaukee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:2778
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15