0

Hi, i want to set a coldfusion variable to undefined within a javascript function, i just written as below, but without calling the method it automatically set the variables on page load. Can anybody help me in the same i want to set the below variable only on call of resetForm(). Please reply me asap. Thanks

function resetForm()
    {

        <cfoutput>
            <cfset form.rdoSensitivity = JavaCast( "null", 0 )/>
            <cfset form.rdoMgtLevel = JavaCast( "null", 0 )/>
        </cfoutput>

        document.getElementById("addButton").disabled = false;
        document.getElementById("removeButton").disabled = false;

    }
3
Contributors
2
Replies
12
Views
3 Years
Discussion Span
Last Post by dipakatcvrca
0

You've got things reversed. By the time the Javascript function executes, ColdFusion has done its work and receded into the background. There's nothing to set.

0

The solution is pretty easy. You have to understand the client side and server side code execution time. As mentioned above by Wayne 3, by the time javascript function is called, ColdFusion is already been executed. To be more specific, First ColdFusion code is executed to get HTML and javascript output, and then when the response reaches to browser, we get a chance to execute javascript code.This is all about client and server side. Now the solution for you.

Use AJAX call from your javascript method to communicate with your server and do whatever ColdFusion operation you want to do. That is the easiest way you can pick. Please use $.ajax to acomplish your task.

Please let me know if this helps you.

Regards,
Dipak

Edited by dipakatcvrca: Sentence formation mistake

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.