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
Jim BoudreauxJim Boudreaux 

Can JavaScript assign values to Apex Controller Variables?

Can JavaScript on a VisualForce page assign values to Apex Controller variables?

 

I have an outputpanel which calls a javascript funtion when clicked. Part of my app requires a variable to get a value when the outputpanel is clicked. I would use the actionsupport or param to assign the value to the variable, but this causes a page refresh or an ajax refresh, neither of which I want. What would be ideal is if the js function I call when clicking the outputpanel could input the value to the variable.

 

Is this possible, or is that what JavaScript Remoting in Spring11 all about?

Best Answer chosen by Admin (Salesforce Developers) 
vhanson222vhanson222

Check out this post, it helped me when i was trying to do something similar.  Passing javascript values to apex controller

 

Hope that helps.

All Answers

vhanson222vhanson222

Check out this post, it helped me when i was trying to do something similar.  Passing javascript values to apex controller

 

Hope that helps.

This was selected as the best answer
cwall_sfdccwall_sfdc

Jim:

 

Javascript Remoting for Apex Controllers requires that remotable Apex Controller methods are static, so controller instance variables are not accessible.