Copy link to clipboard
Copied
Good Morning,
I'm a newbie when it comes to this so I apologize ahead of time.
I'm trying to build a Year/Make/Model related select search. I found a HTML, PHP, and the JQuery Related Select Plugin that i'm trying to convert to use with CF.
It looks like i can use an array to replace the PHP page that supplies static data:
<?php
$stateID = $_GET['stateID'];
$countyID = $_GET['countyID'];
$townID = $_GET['townID'];
$html = $_GET['html'];
$states = array();
$states['MA'] = "Massachusetts";
$states['VT'] = "Vermont";
$states['SC'] = "South Carolina";
$counties = array();
$counties['MA']['BARN'] = 'Barnstable';
$counties['MA']['PLYM'] = 'Plymouth';
$counties['VT']['CHIT'] = 'Chittenden';
$counties['SC']['ANDE'] = 'Anderson';
if($stateID && !$countyID && !$townID){
echo json_encode( $counties[$stateID] );
} elseif( $stateID && $countyID && !$townID ) {
echo json_encode( $towns[$stateID][$countyID] );
} elseif( isset($villages[$stateID][$countyID][$townID]) ) {
echo json_encode( $villages[$stateID][$countyID][$townID] );
} else {
echo '{}';
}
?>
I'm tryiing to convert the following into an array so that i can access it from the index.cfm page:
<cfquery name="qYear" datasource="MyDS" username="MyUser" password="MyPass">
select distinct YearRange
from ExactFit2012
order by YearRange
</cfquery>
<cfquery name="qMake" datasource="MyDS" username="MyUser" password="MyPass">
select distinct Make
from ExactFit2012
order by Make
</cfquery>
<cfquery name="qModel" datasource="MyDS" username="MyUser" password="MyPass">
select distinct Model
from ExactFit2012
order by Model
</cfquery>
<cfset myYear = ListToArray(ValueList(qYear.YearRange)) />
<cfset myMake = ListToArray(ValueList(qMake.Make)) />
<cfset myModel = ListToArray(ValueList(qModel.Model)) />
<Cfoutput>
#myYear#<br>
#myMake#<br>
#myModel#
</Cfoutput>
When i do this i get the error:
Error Occurred While Processing Request | |||
|
index.cfm:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery Related Selects</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="src/jquery.relatedselects.min.js" type="text/javascript"></script>
<style type="text/css">
body { font:12px helvetica, arial, sans-serif; }
</style>
<script type="text/javascript">
$(function(){
$("#example-1, #example-3").relatedSelects({
onChangeLoad: 'MyArray.cfm',
defaultOptionText: 'Choose an Option',
selects: {
'Make': { loadingMessage:'Loading Year...' },
'YearRange': { loadingMessage:'Loading Make...' },
'Model': { loadingMessage:'Loading Model...' },
'OverallSize': {}
}
});
});
</script>
</head>
<body>
<form id="ymm">
<select name="YearID">
<option value="">Choose Year »</option>
<cfoutput query="qYear">
<option value="#YearRange#">#YearRange#</option>
</cfoutput>
</select>
<select name="Make">
<option value="">Choose Make »</option>
</select>
<select name="Model">
<option value="Model">Choose Model »</option>
</select>
<select name="OverallSize">
<option value="">Choose Size »</option>
</select>
</form>
</body>
</html>
I may be going avout this all woring, but i have tried 3 cfc tutorials with no luck so i'm hoping the JQuery Related Select will do the trick.
Cheers,
Aaron
good
Copy link to clipboard
Copied
good