You need to sign in to do that
Don't have an account?
AsitM9
java script variable's value to stored in apex variable
Controller: public class A { public string s{get;set;}; public A() { A= //some how i would like to store the value of s(java script varicble in this variable) } } VF page: <apex:page controller="A"> <script> var s; s='Value to be passed to apex class'; </script> </apex:page>
given approach is not working for me.
plz suggest.
You'll have to modify your class a bit:
Then you can add the following VF to pass the variable (I've included an output section so you can get it working, remove this in your code:
All Answers
Hi Asit,
You can't get javascript value in constructor but you can get it any other function of apex class.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
THe solution given in the link WORKS!
But the catch is you wont be able to access the variable via constructor. You can access variable from a method , once the JS method is called i.e clickMe();
You can automatically call the js by calling the same using js or by using document.ready
You'll have to modify your class a bit:
Then you can add the following VF to pass the variable (I've included an output section so you can get it working, remove this in your code: