I have a question: I need to set the value of an apex:variable (test) equal to a javascript variable (result). You can see my code below:

    window.onload = function(){

        var prodID = document.getElementById("productId").textContent;
        Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.ProductDetailController.retrieveAskForQuoting}', prodID, function(result, event){

            // Success case!

                document.getElementById("visibility").value = result;


How can this be achieved?

  • Please explain why you feel this implementation strategy is necessary. – Adrian Larson May 2 '19 at 17:30
  • I need to pass a value from visualforce to the controller because I need to set a non-static variable and, as per the definition, a remote action needs to be declared as static. Thus, I cannot reference a non-static variable from a static context. – Fabio Vannacci May 3 '19 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.