scripter73
Programmer
Hi,
I have a Cold Fusion query that populates a Cold Fusion array. Now I want to display the query result in a Javascript table for further processing. I was hoping to do this by building another Javascript table based on the values.
I haven't been very successful in creating an array in Javascript to hold the query result.
What am I doing wrong? I'm getting Javascript errors concerning an 'invalid character' on an empty line, and also there's no object.
Following is my code:
Ideally I want to read the values of 'myarray' in Javascript
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Build Dynamic Array From VehicleMk</title>
<!--- <CFQUERY NAME = "VEHCODE" DATASOURCE = "CCMSLRDTA"> --->
<CFQUERY NAME = "VEHCODE" DATASOURCE = "CCMS">
SELECT CODE,DESCRIPTION FROM TBLVEHICLE
</CFQUERY>
<CFLOOP QUERY = "VEHCODE">
<CFSET BOTHFIELDS = LISTAPPEND(VEHCODE.CODE[CurrentRow],VEHCODE.DESCRIPTION[CurrentRow])>
<CFSET myarray[CurrentRow][1] = BOTHFIELDS>
<!--- As loop through array, compare the Description to your selected vehicle. If
there's a match, #session.dbcarmake# = Vehcode.Code of Current Row. --->
</CFLOOP>
<script langage="javascript">
function receive_arr(){
var n=new Array(#vehcode.Recordcount#)
<cfloop query="vehcode">
n[#CurrentRow#]="#vehcode.code[CurrentRow]#"
</cfloop>
for (i=1; i<6; i++){
alert(n);
}//for
}//function
</script>
</head>
<body>
<form>
<SELECT name="car_maker">
<option value="#" selected></option>
<CFOUTPUT query="carmake">
<OPTION value="#carmake.vehicle_make_desc#">#carmake.vehicle_make_desc#
</CFOUTPUT>
</SELECT>
<input type="button" name="Pass Array" value="Pass Array" onclick="receive_arr()";>
</form>
</body>
</html>
Any help you can provide is greatly appreciated.
Thanks in advance,
scripter73
I have a Cold Fusion query that populates a Cold Fusion array. Now I want to display the query result in a Javascript table for further processing. I was hoping to do this by building another Javascript table based on the values.
I haven't been very successful in creating an array in Javascript to hold the query result.
What am I doing wrong? I'm getting Javascript errors concerning an 'invalid character' on an empty line, and also there's no object.
Following is my code:
Ideally I want to read the values of 'myarray' in Javascript
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Build Dynamic Array From VehicleMk</title>
<!--- <CFQUERY NAME = "VEHCODE" DATASOURCE = "CCMSLRDTA"> --->
<CFQUERY NAME = "VEHCODE" DATASOURCE = "CCMS">
SELECT CODE,DESCRIPTION FROM TBLVEHICLE
</CFQUERY>
<CFLOOP QUERY = "VEHCODE">
<CFSET BOTHFIELDS = LISTAPPEND(VEHCODE.CODE[CurrentRow],VEHCODE.DESCRIPTION[CurrentRow])>
<CFSET myarray[CurrentRow][1] = BOTHFIELDS>
<!--- As loop through array, compare the Description to your selected vehicle. If
there's a match, #session.dbcarmake# = Vehcode.Code of Current Row. --->
</CFLOOP>
<script langage="javascript">
function receive_arr(){
var n=new Array(#vehcode.Recordcount#)
<cfloop query="vehcode">
n[#CurrentRow#]="#vehcode.code[CurrentRow]#"
</cfloop>
for (i=1; i<6; i++){
alert(n);
}//for
}//function
</script>
</head>
<body>
<form>
<SELECT name="car_maker">
<option value="#" selected></option>
<CFOUTPUT query="carmake">
<OPTION value="#carmake.vehicle_make_desc#">#carmake.vehicle_make_desc#
</CFOUTPUT>
</SELECT>
<input type="button" name="Pass Array" value="Pass Array" onclick="receive_arr()";>
</form>
</body>
</html>
Any help you can provide is greatly appreciated.
Thanks in advance,
scripter73