Thanks Dan for your reply.
I´m pasting your code as it is on the post of
02/26/2007:
I only had to do this once, and it works. Here it is
<cfquery name="Etiology" datasource="burns">
select EtiologyID, Etiology
from burns_Etiology
where show = <cfqueryparam cfsqltype="cf_sql_char"
value="Y">
</cfquery>
<cfquery name="EtiologyDetail" datasource="burns">
select EtiologyID, EtiologyDetailID, detail
from burns_EtiologyDetail
where show = <cfqueryparam cfsqltype="cf_sql_char"
value="Y">
</cfquery>
// arrays to make selectcontrol script work
idArray =
ListToArray(ValueList(EtiologyDetail.EtiologyDetailID));
compareArray =
ListToArray(ValueList(EtiologyDetail.EtiologyID));
descriptionArray =
ListToArray(ValueList(EtiologyDetail.detail));
another query for the current value, if applicable
<script language="JavaScript">
function selectChange(selectedValue)
{
// changes the options for etilogy detail based on selection
of etiology
<cfoutput>
var #toScript(idArray, "theIdArray")#;
var #toScript(compareArray, "theCompareArray")#;
var #toScript(descriptionArray, "theDescriptionArray")#;
</cfoutput>
var i = 0;
var j = 0;
var len = theIdArray.length;
// clear the detail select control
document.forms['dataForm'].EtiologyDetail.options.length = 0;
for ( i = 0; i < len; i++)
{
if (theCompareArray == selectedValue)
{
document.forms['dataForm'].EtiologyDetail.options = new
Option(theDescriptionArray,theIdArray);
j++;
} // end if
} // end loop
return true;
} // end function
</script>
Function gets called here
<th>Etiology</th>
<td><cfselect query="Etiology" name="Etiology"
onChange="selectChange(this.value);"
value="Etiologyid" display="Etiology"
selected="#selectedEtiology#" />
</td>
<th>Detail</th>
<td colspan="3">
<cfif existingrecord>
<cfselect query="etdetail" value="EtiologyDetailID"
display="detail"
name="EtiologyDetail" selected="#selectedEtiologyDetail#"
/>
<cfelse>
<select name="EtiologyDetail" >
<option value="1">Not Updated</option>
</select>
</cfif>
I don´t see where you set the variable
"selectedEthiology".
Hope this helps.