Custom Search

Thursday, January 24, 2008

Tutorial : cfsavecontent

Copy the below code and paste your editor.Before it you
need two table one tblCountry  with CountryID,CountryName
Column And another tblCounty with CountyID,CountryID,
CountyName Column.Edit code if needed.

<cfquery name="qCountry" datasource="#DataSourceName#">
SELECT * FROM tblCountry
</cfquery>


<cfquery name="qCounty" datasource="#DataSourceName#">
SELECT     CountyID, CountryID,CountyName
FROM         tblCounty
</cfquery>


<cfsavecontent variable="CountyList">

var CountyName = [];

var SelectedCountry=Country.selectedItem.data;


<cfoutput query="qCounty">

var CountryID=#CountryID#;

if (CountryID == SelectedCountry)

{

var AddCounty = {label:'#CountyName#', data:#CountyID#};

CountyName.push(AddCounty);

}

</cfoutput>



County.dataProvider = CountyName;

</cfsavecontent>


<div align="center">
<cfform format="flash" width="300" height="200">

<cfformgroup type="panel" label="Select Country and County">

<cfselect label="Country" name="Country" query="qCountry" value="CountryID" display="CountryName" required="yes" onchange="#CountyList#">

</cfselect>

<cfselect name="County" label="County">

Select

</cfselect>

</cfformgroup>

</cfform>
</div>