views:

70

answers:

2

Hi I have the following code in cf and I want to alert out the values

......
......
<cfelse>

            <cfset val = structFind(request.session.prefs, key)>

            <cfquery name="insertPref" datasource="database">
            INSERT  INTO 
                `database`.`user` (
                    `cID`, 
                    `cliID`, 
                    `userID`, 
                    `userPID`, 
                    `value` 
                )
            SELECT 
                #request.cID#, 
                #request.cliID#, 
                #request.userID#, 
                `user`.`userPID`, 
                <cfqueryparam value="#preserveSingleQuotes(val)#"> 
            FROM 
                `database`.`user` 
            WHERE 
                `applicationID` = 1 

            AND 
                `name` = <cfqueryparam value="#preserveSingleQuotes(key)#"> 
            ON DUPLICATE KEY UPDATE
                `value` = <cfqueryparam value="#preserveSingleQuotes(val)#"> 
            </cfquery>

        </cfif>

    </cfif>

</cfloop>

Any help will be appreciated

+2  A: 

I would use myval due to the fact that val is a function to return an integer.

Did you try:

<cfoutput>
   <script type="text/javascript">
       alert("#myval#");
   </script>
</cfoutput>
cfEngineers
+2  A: 

If you wanna convert CF value to Javascript value, use ToScript.

<cfset thisString="hello world">
<script type="text/javascript" language="JavaScript">
<cfoutput>
var #toScript(thisString, "jsVar")#;
</cfoutput>
</script>
ppshein