function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to Set controller variable from javascript


Can we set the value of controller variable in JavaScript using binding {! }; something same as we  retrieve it by writing



Ritesh AswaneyRitesh Aswaney

You can use apex:actionFunction (though it has been superceded by Javascript remoting more recently)

have a look at this


In a line, an actionFunction has a call to a controller method, and can be invoked by a javascript function, which is invoked on an event. You can also pass parameters to the controller using apex:param




By action function i will call controller method and this will set value of variable.


My question is we can retrieve  controller variable values in javascript by just binding it like {! variable}


Can we also set the value of this variable   from javascript something like {!variable} = value


Sothat i do not have extra overhead of an action function and a method in controller just to set the value.