Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Related Drop Down Selects Size

Status
Not open for further replies.

AlanDI1

Programmer
Apr 20, 2003
56
I have javascript code that I use with Coldfusion to load a second drop down that is related to a selection made in a first drop down. The code works but (isn't there always a but?), it depends on the quantity of items returned by the query.

The results of the query are about 40K entries. When I trim that down for testing purposes to about half that the code works without any errors. When I use all the data, I get a syntax error someplace in the generated arrays (exact location varies depending on the size of the result set).

Not sure if the problem is the number of arrays, the size of the arrays, total number of elements or something else.

<----- Code ------>
<!--- Select the Types and IDs. --->
<cfquery datasource="pb_view" name="GetIds">
SELECT DISTINCT Fac_Type, Fac_Ident
FROM dbo.ListTable_facility, dbo.naprs_reportable_facilities
WHERE Facility = Fac_type
ORDER BY Fac_Type, Fac_ident
</cfquery>

<script language = "JavaScript">
<!--
// For each type, create an array to hold the idents.
<cfoutput query="GetIds" group="Fac_Type">
// Create the array
TypeArray#Fac_Type# = new Array();
<cfset i = 0>
// Populate the array
<cfoutput>
<cfset i = i + 1>
TypeArray#Fac_Type#[#i#] = "#Fac_Ident#";
</cfoutput>
</cfoutput>

// Function to populate the Ident for the Type selected
function PopulateIdent() {
// Only process the function if the first item is not selected.
if (document.selectedForm.Fac_Type.selectedIndex != 0) {
// Find the state abbreviation
var ThisType = document.selectedForm.Fac_Type[document.selectedForm.Fac_Type.selectedIndex].value;
// Set the length of the ident drop down equal to the length of the type's array
document.selectedForm.Fac_Ident.length = eval("TypeArray" + ThisType + ".length");
// Put 'Select' as the first option in the ident drop-down
document.selectedForm.Fac_Ident[0].value = "";
document.selectedForm.Fac_Ident[0].text = "Select";
document.selectedForm.Fac_Ident[0].selected = true;
// Loop through the state's array and populate the area code drop down.
for (i=1; i<eval("TypeArray" + ThisType + ".length"); i++) {
document.selectedForm.Fac_Ident.value = eval("TypeArray" + ThisType + "");
document.selectedForm.Fac_Ident.text = eval("TypeArray" + ThisType + "");
}
}
}
//-->
</script>

<form name="selectedForm">
<p>
<table border="0">
<tr>
<td><b>Type</b></td>
<td><b>Ident</b></td>
</tr>
<tr>
<td>
<select name="Fac_Type" onChange="javascript:populateIdent();">
<option value="0">Select Type</option>
<cfoutput query="GetIds" group="Fac_Type">
<option value="#Fac_Type#">#Fac_Type#</option>
</cfoutput>
</select>
</td>
<td>
<select name="Fac_Ident" width="70" style="width:180" >
<option value="0">Select Facility</option>
</select>
</td>
</tr>
</table>
</p>
</form>

Does anyone have any ideas and if so how do you increase whatever that it is to make this work.

 
Perhaps you could post a URL to a live version of the page with all the data that is giving the error? What you've posted is no good to anyone trying to work out if it's data related or not.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for your help.

First, this is an intranet site only and I don't have a public location where I can publish the page.

The data is strictly characters and spaces. The point it fails at is a definitely 4 characters in the assignment

TypeArraySX [210] = "BGRA";

If I save the viewed source to HTML and move that whole section higher up in the code it works and the code then fails at a line that worked in the past.

Not sure where this leaves me other not to use this code.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top