How do I reference a coldfusion query’s result in a javascript function?
<CFQUERY name ="getPin" datasource = "pins">
SELECT pin
FROM pinuser
where email="#getEmail#"
</cfquery>
I want to set the pin, as a JavaScript variable called pincode, I tried:
var <cfoutput>#ToScript(#pin#,"pincode")#;</cfoutput>
then
alert(pincode)
but it doesnt work, any ideas?
This should work:
I would also include a “top 1” in the SQL or maxrows=1 in the cfquery tag, unless the email is the primary key of the table or otherwise has a unique constraint.