When I execute the code below, resources_gathered is a string, but I get the following error ('Rx222y280.....' is the string in the column resources_gathered):
visualize_resources.cfm?subject_id=395229:105 Uncaught ReferenceError: Rx222y208Rx224y208Rx224y210Rx244y231Rx246y231Rx246y233Rx233y244Rx217y243R is not defined
<cfquery name="getField" datasource="exmind" result="result">
select resources_gathered, completed_fields from dbo.sf
where subject_id=#subject_id#
</cfquery>
<cfset record = getField>
resourcesGathered = JSON.stringify(eval(<cfoutput>#record.resources_gathered#</cfoutput>));
//resourcesGathered = (<cfoutput>#record.resources_gathered#</cfoutput>).toString();
alert(resourcesGathered);
I have tried formatting the string differently before it gets inserted into the table, but I get a reference error anytime I have to read it. Below you can see how I insert it into the table (all code below this point happens in another html file):
<cfquery datasource="exmind">
update dbo.sf
set resources_gathered = <cfqueryparam value="#resources_gathered#"
cfsqltype="cf_sql_nvarchar">
where subject_id = #subject_id#
</cfquery>
The table is correct when I do this, so I am unsure what I need to change to be able to use this data in another html file. I am able to insert/select integers (such as completed_fields) which have been converted to strings, but not this more complex string. Below you can see how the string gets created. It is passed to the query html using a cfform.
for (i=0; i<resources.length; i++) { //resources is an array
if (resources[i].visibility == true){
resourcesFormString += "x";
resourcesFormString += resources[i].x.toString(); //x and y are ints
resourcesFormString += "y";
resourcesFormString += resources[i].y.toString();
resourcesFormString += "R";
}
}
document.getElementById("resources_gathered").value = resourcesFormString;