I want to pass a javascript variable into the controller of my visualforce page. Using <apex:param value="JAVASCRIPTVARIABLE" /> is throwing me an error because it expects JAVASCRIPTVARIABLE to be an exposed property of the controller. Please tell me how to pass the value of JAVASCRIPTVARIABLE to a variable in the controller. Thanks in advance.
Asked
Active
Viewed 510 times
0
Prajith
- 1,559
- 1
- 18
- 37
-
you can achieve this by using actionFunction.. What have you tried so far? – DOMINIC EDWARD Feb 11 '16 at 07:43
-
@DOMINICEDWARD Achieved this using actionFunction and apex:param . Thank you – Prajith Feb 11 '16 at 17:34
1 Answers
3
Here is a SFSE link which talks about how to pass javascript values to controller. It explains how to use <apex:param also. Hope this helps.
Snippets
<!-- A new value will be set to the apex:param -->
<apex:actionFunction name="passStringToController" action="{!myMethod}" rerender="myHiddenField">
<apex:param name="p1" value="" assignTo="{!myString}" />
</apex:actionFunction>
<!-- Here we can directly access the action function per name and assign a variable value -->
<apex:commandButton value="Test me" onclick="passStringToController('new value'); return false;" />
Saroj Bera
- 14,699
- 2
- 17
- 35
-
@Stygon If it answers your question, please mark it as answer. It will help others. – Saroj Bera Feb 12 '16 at 04:13