Array problem - Related Selects
good morning,
i'm newbie when comes apologize ahead of time.
i'm trying build year/make/model related select search. found html, php, , jquery related select plugin i'm trying convert use cf.
it looks can use array replace php page 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 convert following array can access index.cfm page:
<cfquery name="qyear" datasource="myds" username="myuser" password="mypass">
select distinct yearrange
exactfit2012
order yearrange
</cfquery>
<cfquery name="qmake" datasource="myds" username="myuser" password="mypass">
select distinct make
exactfit2012
order make
</cfquery>
<cfquery name="qmodel" datasource="myds" username="myuser" password="mypass">
select distinct model
exactfit2012
order 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 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 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 going avout woring, have tried 3 cfc tutorials no luck i'm hoping jquery related select trick.
cheers,
aaron
good
More discussions in ColdFusion
adobe
Comments
Post a Comment