User Guide

ToScript 891
{
document.write("myArray[" + i + "]: " + jsArray[i] + "<br>");
}
</script>
<br>
<h3>Converting a query</h3>
This section converts the following query object to both WDDX format
and ActionScript type Javascript objects.<br>
<!--- Query a database --->
<cfquery name="thisQuery" datasource="cfdocexamples">
SELECT FirstName,LastName
FROM employee
WHERE FirstName = 'John'
</cfquery>
<br>
The Query in ColdFusion
<cftable query="thisQuery" headerlines="1" colheaders>
<cfcol align="left" width="9" header="<b>FirstName</b>" text="#FirstName#">
<cfcol align="left" width="9" header="<b>LastName</b>" text="#LastName#">
</cftable>
<strong>JavaScript generated by ToScript(thisQuery, "WDDXQuery"):</strong><br>
#toScript(thisQuery, "WDDXQuery")#;<br>
<br>
<strong>JavaScript generated by ToScript(thisQuery, "ActionScriptQuery",
False):</strong><br>
#toScript(thisQuery, "ActionScriptQuery", False)#<br>
<br>
<!--- Convert to both WDDX format and ActionScript format --->
<script type="text/javascript" language="JavaScript">
#ToScript(thisQuery, "WDDXQuery")#;
#ToScript(thisQuery, "ActionScriptQuery", False)#;
</script>
<!--- For brevity, this example does not use JavaScript query variables --->
</cfoutput>